Skip to content

Configure publishing to github pages #6

Configure publishing to github pages

Configure publishing to github pages #6

Workflow file for this run

name: github pages
on:
push:
branches:
- main
pull_request:
permissions:
id-token: write
contents: write
pull-requests: write
checks: write
jobs:
deploy:
runs-on: ubuntu-20.04
env:
PR_PATH: pull/${{github.event.number}}
steps:
- name: Add In Progress Preview Status PR Check
if: github.ref != 'refs/heads/main'
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository_owner }}${{ github.event.repository.name }}/check-runs \
-d '{"name":"PR Preview", "head_sha":"${{github.sha}}", "status": "in_progress"}'
- name: Set domain
run: echo "DOMAIN=${{ github.repository_owner }}.github.io" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: "NPM Install, Build, and Cache"
id: npm-install-build-and-cache
uses: ./.github/actions/npm-install-build-and-cache
- name: "Run Publish Script"
run: ./publish/publish.sh
- name: Set production base URL
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/" >> $GITHUB_ENV
- name: Deploy if this is the `main` branch
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./publish/build
- name: Set base URL for preview if PR
if: github.ref != 'refs/heads/main'
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV
- name: Deploy to PR preview
uses: peaceiris/actions-gh-pages@v3
if: github.ref != 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./publish/build
destination_dir: ${{ env.PR_PATH }}
- name: Add Completed Preview URL PR Check
if: github.ref != 'refs/heads/main'
run: |

Check failure on line 69 in .github/workflows/gh-pages.yml

View workflow run for this annotation

GitHub Actions / github pages

Invalid workflow file

The workflow is not valid. .github/workflows/gh-pages.yml (Line: 69, Col: 14): Unrecognized named-value: 'BASE_URL'. Located at position 1 within expression: BASE_URL
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository_owner }}${{ github.event.repository.name }}/check-runs \
-d '{"name":"PR Preview", "head_sha":"${{github.sha}}", "status": "completed", "details_url": "${{BASE_URL}}"}'