ci: publish review docs #15
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
name: Publish review docs | |
on: | |
push: | |
branches-ignore: | |
- main | |
permissions: | |
contents: read | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
env: | |
TARGET_PATH: "/docs/${{ github.ref_name }}" | |
NEXT_BASE_PATH: "/flow-previews/docs/${{ github.ref_name }}" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ⬇️ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node 🎛️ | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "yarn" | |
registry-url: "https://registry.npmjs.org" | |
- name: Yarn Install 📦️ | |
run: yarn install --immutable | |
- name: Setup NX 1/2 🎛️ | |
uses: nrwl/nx-set-shas@v4 | |
- name: Setup NX 2/2 🎛 | |
if: github.ref != 'refs/heads/main' | |
run: git branch --track main origin/main | |
- name: Build 🔨 | |
run: yarn nx affected -t build --parallel=3 | |
- name: Upload artifact ⬆️ | |
uses: actions/upload-artifact@v4 | |
with: | |
path: packages/docs/out | |
name: site | |
deploy: | |
environment: | |
name: github-pages-preview | |
url: https://mittwald.github.io${{ env.NEXT_BASE_PATH }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download the artifact ⬇️ | |
uses: actions/download-artifact@v4 | |
with: | |
name: site | |
path: docs | |
- name: | |
Bypassing Jekyll on GitHub Pages | |
(https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/) | |
run: touch docs/.nojekyll | |
- name: Upload files to GitHub Pages 🚀 | |
uses: cpina/github-action-push-to-another-repository@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.PUBLISH_PAT }} | |
with: | |
source-directory: "docs" | |
destination-github-username: "mittwald" | |
destination-repository-name: "flow-previews" | |
target-branch: main | |
target-directory: "${{ env.TARGET_PATH }}" | |
- name: Output the URL | |
run: echo "${{ job.environment.url }}" | |
comment-on-pull-request: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
# Only run if a comment was not already made | |
if: | |
${{ github.event_name == 'pull_request' && github.event.action == 'opened' | |
&& !contains(github.event.pull_request.body, 'A [live preview]') }} | |
steps: | |
- uses: actions/github-script@v5 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'A [live preview](${{ job.environment.url }}) is being deployed!<br><br>Please note that it may take a few seconds for GitHub Pages to build and deploy.' | |
}) |