Skip to content

Commit e28dd30

Browse files
committed
ci(blocked_pr): merge env setup for dispatch and pull_request events
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
1 parent 72aee5c commit e28dd30

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

.github/workflows/blocked-prs.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,6 @@ jobs:
3030
uses: actions/checkout@v4
3131
with:
3232
ref: ${{ github.event.repository.default_branch }}
33-
- name: Setup From Pull Request Event
34-
if: github.event_name != 'workflow_dispatch'
35-
id: pr_event_setup
36-
env:
37-
PR_JSON: "${{ toJSON(github.event.pull_request) }}"
38-
run: |
39-
# setup env for the rest of the workflow
40-
{
41-
echo "REPO=$(jq -r '.base.repo.name' <<< "$PR_JSON")"
42-
echo "OWNER=$(jq -r '.base.repo.owner.login' <<< "$PR_JSON")"
43-
echo "PR_NUMBER=$(jq -r '.number' <<< "$PR_JSON")"
44-
echo "JOB_DATA=$(jq -c '
45-
{
46-
"repo": .base.repo.name,
47-
"owner": .base.repo.owner.login,
48-
"repoUrl": .base.repo.html_url,
49-
"prNumber": .number,
50-
"prHeadSha": .head.sha,
51-
"prHeadLabel": .head.label,
52-
"prBody": .body,
53-
"prLabels": (reduce .labels[].name as $l ([]; . + [$l]))
54-
}
55-
' <<< "$PR_JSON")"
56-
} >> "$GITHUB_ENV"
5733

5834
- name: Setup From Dispatch Event
5935
if: github.event_name == 'workflow_dispatch'
@@ -71,6 +47,13 @@ jobs:
7147
-H "X-GitHub-Api-Version: 2022-11-28" \
7248
"/repos/$OWNER/$REPO/pulls/$PR_NUMBER"
7349
)
50+
echo "PR_JSON=$PR_JSON" >> "$GITHUB_ENV"
51+
52+
- name: Setup Environment
53+
id: env_setup
54+
run: |
55+
# setup env for the rest of the workflow
56+
PR_JSON=${PR_JSON:-'${{ toJSON(github.event.pull_request) }}'}
7457
{
7558
echo "REPO=$(jq -r '.base.repo.name' <<< "$PR_JSON")"
7659
echo "OWNER=$(jq -r '.base.repo.owner.login' <<< "$PR_JSON")"
@@ -89,6 +72,7 @@ jobs:
8972
' <<< "$PR_JSON")"
9073
} >> "$GITHUB_ENV"
9174
75+
9276
- name: Find Blocked/Stacked PRs in body
9377
id: pr_ids
9478
run: |
@@ -160,7 +144,7 @@ jobs:
160144
161145
- name: Add 'blocked' Label is Missing
162146
id: label_blocked
163-
if: fromJSON(steps.pr_ids.outputs.prs).numBlocking > 0 && && !contains(fromJSON(env.JOB_DATA).prLabels, 'blocked') && !fromJSON(steps.blocking_data.outputs.all_merged)
147+
if: (fromJSON(steps.pr_ids.outputs.prs).numBlocking > 0) && !contains(fromJSON(env.JOB_DATA).prLabels, 'blocked') && !fromJSON(steps.blocking_data.outputs.all_merged)
164148
continue-on-error: true
165149
env:
166150
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/merge-blocking-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
# a pr that was a `blocking:<id>` label was merged.
1414
# find the open pr's it was blocked by and trigger a refresh of their state
15-
if: github.event.pull_request.merged == true && contains( join( github.event.pull_request.labels.*.name, ',' ), "blocking" )
15+
if: github.event.pull_request.merged == true && contains( join( github.event.pull_request.labels.*.name, ',' ), 'blocking' )
1616

1717
permissions:
1818
issues: write

0 commit comments

Comments
 (0)