Browse Source

set backend and version env

pull/16/head
hole-thu 3 years ago
parent
commit
9b2b8d71b5
  1. 11
      .github/workflows/deploy.yml
  2. 2
      package.json
  3. 2
      src/Common.js
  4. 4
      src/infrastructure/widgets.js

11
.github/workflows/deploy.yml

@ -1,4 +1,4 @@
name: Deploy name: Auto Deploy
on: on:
push: push:
@ -16,11 +16,16 @@ jobs:
cache: 'yarn' cache: 'yarn'
- name: "Install Dependencies" - name: "Install Dependencies"
run: yarn run: yarn
- name: "Get current date"
id: "date"
run: echo "::set-output name=date::$(date --rfc-3339=date)"
- name: Deploy with gh-pages - name: Deploy with gh-pages
run: | run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
yarn deploy -- -u "github-actions-bot <[email protected]>" yarn deploy -u "github-actions-bot <[email protected]>" -m "$COMMIT_MESSAGE"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_REPOSITORY: ${{ github.repository }}
REACT_APP_BACKEND: "https://t-hole.red/"
REACT_APP_BUILD_INFO: version-${{steps.date.outputs.date}}
COMMIT_MESSAGE: "Build for: ${{ github.event.head_commit.message }}"

2
package.json

@ -24,7 +24,7 @@
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "echo 'skipped react-scripts test --env=jsdom'", "test": "echo 'skipped react-scripts test --env=jsdom'",
"predeploy": "REACT_APP_BUILD_INFO=autodeploy-$(TZ=Asia/Shanghai date +\"%y%m%d_%H:%M:%S\") react-scripts build", "predeploy": "react-scripts build",
"deploy": "gh-pages -d build", "deploy": "gh-pages -d build",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"lint": "eslint --fix src/*.js" "lint": "eslint --fix src/*.js"

2
src/Common.js

@ -15,7 +15,7 @@ import renderMd from './Markdown';
export { format_time, Time, TitleLine }; export { format_time, Time, TitleLine };
export const API_BASE = '/_api/v1'; export const API_BASE = `${process.env.REACT_APP_BACKEND || '/'}_api/v1`;
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex // https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
function escape_regex(string) { function escape_regex(string) {

4
src/infrastructure/widgets.js

@ -82,7 +82,9 @@ class LoginPopupSelf extends Component {
<b>通过第三方验证登陆新T树洞</b> <b>通过第三方验证登陆新T树洞</b>
</p> </p>
<p> <p>
<a href="/_login?p=cs" target="_blank"> <a href={(process.env.REACT_APP_BACKEND || '/') + "_login?p=cs"} target="_blank"
referrerPolicy="origin"
>
<span className="icon icon-login" /> <span className="icon icon-login" />
&nbsp;闭社 &nbsp;闭社
</a> </a>

Loading…
Cancel
Save