Deployment to GitHub Pages #1333
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: Deployment to GitHub Pages | |
on: | |
# call this workflow when the workflow Main Validation is completed after a push to main | |
workflow_run: | |
workflows: | |
- 'Main Validation' | |
branches: | |
- main | |
types: | |
- completed | |
jobs: | |
deploy: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
concurrency: react-boilerplate-deployment | |
environment: production | |
steps: | |
- name: Begin CI... | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: .node-version | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
run: | | |
echo "::set-output name=dir::$(npm config get cache)" | |
- uses: actions/cache@v3 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm install | |
- name: Make envfile | |
uses: SpicyPizza/create-envfile@v1 | |
with: | |
file_name: .env | |
envkey_VITE_APP_BASE_URL: /react-boilerplate/ | |
- name: Build page | |
run: npm run build | |
env: | |
VITE_APP_BASE_URL: /react-boilerplate/ | |
- name: Deploy to gh-pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist |