Skip to content

Commit e15cec1

Browse files
authored
Merge pull request #37 from patternfly-extension-testing/pr-preview-update
fix: inline permissions check and simplify pr-preview workflow
2 parents 571d223 + 3c17491 commit e15cec1

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

.github/workflows/pr-preview.yml

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,40 @@ on:
66

77
jobs:
88
check-permissions:
9-
uses: patternfly/.github/.github/workflows/check-team-membership.yml@main
10-
secrets: inherit
9+
runs-on: ubuntu-latest
10+
if: >-
11+
github.event_name == 'pull_request_target' ||
12+
(github.event_name == 'issue_comment' &&
13+
github.event.issue.pull_request &&
14+
contains(github.event.comment.body, '/deploy-preview'))
15+
outputs:
16+
allowed: ${{ steps.check-team.outputs.allowed }}
17+
pr-number: ${{ steps.check-team.outputs.number }}
18+
steps:
19+
- name: Get PR info and check permissions
20+
id: check-team
21+
env:
22+
EVENT_NAME: ${{ github.event_name }}
23+
PR_NUMBER: ${{ github.event.pull_request.number }}
24+
PR_ASSOCIATION: ${{ github.event.pull_request.author_association }}
25+
COMMENT_NUMBER: ${{ github.event.issue.number }}
26+
COMMENT_ASSOCIATION: ${{ github.event.comment.author_association }}
27+
run: |
28+
if [[ "$EVENT_NAME" == "pull_request_target" ]]; then
29+
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
30+
ASSOCIATION="$PR_ASSOCIATION"
31+
else
32+
echo "number=$COMMENT_NUMBER" >> $GITHUB_OUTPUT
33+
ASSOCIATION="$COMMENT_ASSOCIATION"
34+
fi
35+
36+
if [[ "$ASSOCIATION" == "OWNER" || "$ASSOCIATION" == "MEMBER" || "$ASSOCIATION" == "COLLABORATOR" ]]; then
37+
echo "allowed=true" >> $GITHUB_OUTPUT
38+
echo "User is a repo $ASSOCIATION — allowed"
39+
else
40+
echo "allowed=false" >> $GITHUB_OUTPUT
41+
echo "User association is $ASSOCIATION — not allowed"
42+
fi
1143
1244
deploy-preview:
1345
runs-on: ubuntu-latest
@@ -20,15 +52,9 @@ jobs:
2052
GH_PR_NUM: ${{ needs.check-permissions.outputs.pr-number }}
2153
steps:
2254
- uses: actions/checkout@v4
23-
# Checkout the PR branch
2455
- run: |
2556
git fetch origin pull/$GH_PR_NUM/head:tmp
2657
git checkout tmp
27-
- run: |
28-
git rev-parse origin/main
29-
git rev-parse HEAD
30-
git rev-parse origin/main..HEAD
31-
git log origin/main..HEAD --format="%b"
3258
- uses: actions/setup-node@v4
3359
with:
3460
node-version: '22'
@@ -40,28 +66,14 @@ jobs:
4066
path: |
4167
node_modules
4268
**/node_modules
43-
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
69+
key: ${{ runner.os }}-yarn-22-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
4470
- run: yarn install --immutable
4571
if: steps.yarn-cache.outputs.cache-hit != 'true'
4672
- run: yarn build
4773
name: Build
48-
- uses: actions/cache@v4
49-
id: docs-cache
50-
name: Load webpack cache
51-
with:
52-
path: '.cache'
53-
key: ${{ runner.os }}-v4-${{ hashFiles('yarn.lock') }}
5474
- run: yarn build:docs
5575
name: Build docs
5676
- name: Upload docs
5777
uses: patternfly/.github/.github/actions/surge-preview@main
58-
if: always()
5978
with:
6079
folder: packages/module/public
61-
- run: yarn serve:docs & yarn test:a11y
62-
name: a11y tests
63-
- name: Upload a11y report
64-
uses: patternfly/.github/.github/actions/surge-preview@main
65-
if: always()
66-
with:
67-
folder: packages/module/coverage

0 commit comments

Comments
 (0)