Manual Push to GitHub Pages #103
This file contains hidden or 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: Manual Push to GitHub Pages | |
| on: | |
| workflow_dispatch: | |
| #pull_request: | |
| # branches: | |
| # - main | |
| # Review gh actions docs if you want to further define triggers, paths, etc | |
| # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| test-build: | |
| name: Test and Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: ./package-lock.json | |
| - name: Build website | |
| #working-directory: ./ | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Run Tests | |
| #working-directory: ./ | |
| run: | | |
| npm test | |
| - name: Upload Build Artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: build | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: test-build | |
| # Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
| permissions: | |
| pages: write # to deploy to Pages | |
| id-token: write # to verify the deployment originates from an appropriate source | |
| # Deploy to the github-pages environment | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set Environment variable for Staging | |
| if: github.ref == 'refs/heads/staging' | |
| run: echo "DEPLOY_ENV=staging" >> $GITHUB_ENV | |
| - name: Set Environment variable for Production | |
| if: github.ref == 'refs/heads/main' | |
| run: echo "DEPLOY_ENV=production" >> $GITHUB_ENV | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |