deploying gh-pages2 #3
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: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
test-build: | |
name: Test & Build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16.x | |
- name: Install dependencies | |
run: npm ci | |
- name: test the code | |
run: npm test | |
- name: build the code | |
run: npm run build | |
- name: Deploying to gh-pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist | |
- name: Build | |
env: | |
VITE_APP_PUBLIC_URL: /example-react-cicd/ | |
# TODO: Run tests here | |
# TODO: Run build here | |
# TODO: Deploy to github pages | |
## TIP | |
## to conditionally run a job or a step use the if key. | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
## TIP | |
## deploy steps and permissions for the Github token needed to deploy to gh-pages | |
# permissions: | |
# contents: write | |
# steps: | |
# - name: Deploying to gh-pages | |
# uses: peaceiris/actions-gh-pages@v3 | |
# with: | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# publish_dir: ./dist | |
## TIP: | |
## to deploy to GH pages, set this env var in the build step | |
# - name: Build | |
# env: | |
# VITE_APP_PUBLIC_URL: /<repo_name>/ | |
## TIP: | |
## If you need to share files between jobs upload them in the repo and download them in the destination job | |
# - name: Uploading build files | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: artifact | |
# path: ./dist | |
# - name: Downloading artifact | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
# uses: actions/download-artifact@v2 | |
# with: | |
# name: artifact | |
# path: ./dist |