From e437bc4e161108f50db11b39e7d6f0bcf1ce197c Mon Sep 17 00:00:00 2001 From: nicolethoen Date: Wed, 1 Apr 2026 11:57:03 -0400 Subject: [PATCH 1/2] chore: add PR preview workflow for docs and dev app Publishes both the docs site and dev app to surge on PRs, using the shared patternfly surge-preview action with contributor permission checks. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/pr-preview.yml | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/pr-preview.yml diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 00000000..d96e55f3 --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,85 @@ +name: pr-preview +on: + pull_request_target: + issue_comment: + types: [created] + +jobs: + check-permissions: + runs-on: ubuntu-latest + if: >- + github.event_name == 'pull_request_target' || + (github.event_name == 'issue_comment' && + github.event.issue.pull_request && + contains(github.event.comment.body, '/deploy-preview')) + outputs: + allowed: ${{ steps.check-team.outputs.allowed }} + pr-number: ${{ steps.check-team.outputs.number }} + steps: + - name: Get PR info and check permissions + id: check-team + env: + EVENT_NAME: ${{ github.event_name }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_ASSOCIATION: ${{ github.event.pull_request.author_association }} + COMMENT_NUMBER: ${{ github.event.issue.number }} + COMMENT_ASSOCIATION: ${{ github.event.comment.author_association }} + run: | + if [[ "$EVENT_NAME" == "pull_request_target" ]]; then + echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + ASSOCIATION="$PR_ASSOCIATION" + else + echo "number=$COMMENT_NUMBER" >> $GITHUB_OUTPUT + ASSOCIATION="$COMMENT_ASSOCIATION" + fi + + if [[ "$ASSOCIATION" == "OWNER" || "$ASSOCIATION" == "MEMBER" || "$ASSOCIATION" == "COLLABORATOR" ]]; then + echo "allowed=true" >> $GITHUB_OUTPUT + echo "User is a repo $ASSOCIATION — allowed" + else + echo "allowed=false" >> $GITHUB_OUTPUT + echo "User association is $ASSOCIATION — not allowed" + fi + + deploy-preview: + runs-on: ubuntu-latest + needs: check-permissions + if: needs.check-permissions.outputs.allowed == 'true' + env: + SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }} + GH_PR_NUM: ${{ needs.check-permissions.outputs.pr-number }} + steps: + - uses: actions/checkout@v4 + - run: | + git fetch origin pull/$GH_PR_NUM/head:tmp + git checkout tmp + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + - run: corepack enable + - uses: actions/cache@v4 + id: yarn-cache + name: Cache yarn deps + with: + path: | + node_modules + **/node_modules + key: ${{ runner.os }}-yarn-22-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --immutable + if: steps.yarn-cache.outputs.cache-hit != 'true' + - run: yarn build:docs + name: Build docs + - run: yarn dev:build + name: Build dev app + - name: Upload docs preview + uses: patternfly/.github/.github/actions/surge-preview@main + with: + folder: packages/module/public + - name: Rename dev output for unique surge URL + run: mv packages/dev/public packages/dev/dev-app + - name: Upload dev app preview + uses: patternfly/.github/.github/actions/surge-preview@main + with: + folder: packages/dev/dev-app From 66249fc79912bcf824ab4ae9a8d98ca41cef6d39 Mon Sep 17 00:00:00 2001 From: nicolethoen Date: Wed, 1 Apr 2026 12:00:50 -0400 Subject: [PATCH 2/2] chore: hardcode node 20 in pr-preview workflow Aligns with the node version used in the existing CI workflow rather than reading from .nvmrc which specifies v18. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index d96e55f3..acd10a35 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -57,7 +57,7 @@ jobs: git checkout tmp - uses: actions/setup-node@v4 with: - node-version-file: '.nvmrc' + node-version: '20' - run: corepack enable - uses: actions/cache@v4 id: yarn-cache