Deploy demo via Github action #54
Workflow file for this run
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
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
# Allows to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: env | sort | |
- name: Install React | |
run: npm install react react-dom prop-types | |
- run: npm install | |
- name: Install example | |
run: cd ./example && npm install && cd .. | |
- run: npm run build | |
- name: Run Cypress tests | |
run: | | |
npm run build & | |
cd ./example && npm run start:silent & | |
npm run cypress:run -- --record --key ${{ secrets.CYPRESS_KEY }} | |
buildDemo: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install React | |
run: npm install react react-dom prop-types | |
- run: npm install | |
- run: npm run build | |
- name: Install example | |
run: cd ./example && npm install && cd .. | |
# By default, react builds the index.html links with absolute paths. However, the github pages deployment is under a folder name (usually the repo name). Therefore, we must make sure that the index.html links are relative | |
- name: Set public url | |
run: cd ./example && echo "PUBLIC_URL=." >> $GITHUB_ENV | |
- name: Build demo | |
run: cd ./example && npm run build && cd .. | |
- name: Publish demo artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./example/build | |
deployGithubPages: | |
needs: buildDemo | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |