finish #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Production CI | |
on: | |
push: | |
branches: [main] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
buildAndDeploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- run: git submodule update --init --recursive | |
- name: Save original git author and git email | |
run: | | |
echo "git_email=$(git log --format='%ae' HEAD^!)" >> $GITHUB_ENV | |
echo "git_name=$(git log --format='%an' HEAD^!)" >> $GITHUB_ENV | |
- uses: actions/[email protected] | |
- name: Change homepage in package.json | |
run: sed -i 's/place-holder/OATutor/g' package.json | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Run CI install | |
run: npm ci | |
- name: Run build | |
run: npm run build | |
env: | |
REACT_APP_OPENAI_KEY: ${{ secrets.OPENAI_KEY }} | |
CI: false | |
REACT_APP_BUILD_TYPE: "production" | |
REACT_APP_COMMIT_HASH: ${{ github.sha }} | |
- uses: actions/checkout@v2 | |
with: | |
ref: "gh-pages" | |
path: "gh-build" | |
- name: Push | |
run: | | |
cd gh-build | |
git rm -rf . | |
git clean -fxd | |
rsync -av ../build/ . | |
git add . | |
git config --local user.email "${{ env.git_email }}" | |
git config --local user.name "${{ env.git_name }}" | |
git diff --cached --quiet --exit-code && echo "no changes to platform, exiting early" && exit 0 | |
git commit -m "deploy commit: CAHLR/OATutor@$GITHUB_SHA" | |
git push |