Support preview from forked repositories (#155) #5277
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: Publish website | |
on: | |
schedule: | |
- cron: '0 */6 * * *' | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
defaults: | |
run: | |
shell: bash | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install packages | |
run: npm i | |
- name: Generate Site | |
run: npm run build | |
- name: Store PR id | |
run: echo ${{ github.event.number }} > pr-id.txt | |
- name: Publishing directory for PR preview | |
uses: actions/upload-artifact@v4 | |
with: | |
name: site | |
path: build/site | |
retention-days: 1 | |
deploy: | |
# Only try and deploy on merged code | |
if: "github.repository == 'quarkiverse/quarkiverse-docs' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')" | |
needs: [ build ] | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 # not needed for the code, but needed for the git config | |
- name: Download Built site | |
uses: actions/download-artifact@v4 | |
with: | |
name: site | |
path: build/site | |
- name: Deploy | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: site # The folder the action should deploy. |