mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-20 16:27:15 +02:00
ci(blocked_pr): merge env setup for dispatch and pull_request events
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
72aee5c9f6
commit
e28dd30d87
60
.github/workflows/blocked-prs.yml
vendored
60
.github/workflows/blocked-prs.yml
vendored
@ -30,13 +30,30 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.repository.default_branch }}
|
||||
- name: Setup From Pull Request Event
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
id: pr_event_setup
|
||||
|
||||
- name: Setup From Dispatch Event
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
id: dispatch_event_setup
|
||||
env:
|
||||
PR_JSON: "${{ toJSON(github.event.pull_request) }}"
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ inputs.pr_id }}
|
||||
run: |
|
||||
# setup env for the rest of the workflow
|
||||
OWNER=$(dirname "${{ github.repository }}")
|
||||
REPO=$(basename "${{ github.repository }}")
|
||||
PR_JSON=$(
|
||||
gh api \
|
||||
-H "Accept: application/vnd.github.raw+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
"/repos/$OWNER/$REPO/pulls/$PR_NUMBER"
|
||||
)
|
||||
echo "PR_JSON=$PR_JSON" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Setup Environment
|
||||
id: env_setup
|
||||
run: |
|
||||
# setup env for the rest of the workflow
|
||||
PR_JSON=${PR_JSON:-'${{ toJSON(github.event.pull_request) }}'}
|
||||
{
|
||||
echo "REPO=$(jq -r '.base.repo.name' <<< "$PR_JSON")"
|
||||
echo "OWNER=$(jq -r '.base.repo.owner.login' <<< "$PR_JSON")"
|
||||
@ -55,39 +72,6 @@ jobs:
|
||||
' <<< "$PR_JSON")"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Setup From Dispatch Event
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
id: dispatch_event_setup
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ inputs.pr_id }}
|
||||
run: |
|
||||
# setup env for the rest of the workflow
|
||||
OWNER=$(dirname "${{ github.repository }}")
|
||||
REPO=$(basename "${{ github.repository }}")
|
||||
PR_JSON=$(
|
||||
gh api \
|
||||
-H "Accept: application/vnd.github.raw+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
"/repos/$OWNER/$REPO/pulls/$PR_NUMBER"
|
||||
)
|
||||
{
|
||||
echo "REPO=$(jq -r '.base.repo.name' <<< "$PR_JSON")"
|
||||
echo "OWNER=$(jq -r '.base.repo.owner.login' <<< "$PR_JSON")"
|
||||
echo "PR_NUMBER=$(jq -r '.number' <<< "$PR_JSON")"
|
||||
echo "JOB_DATA=$(jq -c '
|
||||
{
|
||||
"repo": .base.repo.name,
|
||||
"owner": .base.repo.owner.login,
|
||||
"repoUrl": .base.repo.html_url,
|
||||
"prNumber": .number,
|
||||
"prHeadSha": .head.sha,
|
||||
"prHeadLabel": .head.label,
|
||||
"prBody": .body,
|
||||
"prLabels": (reduce .labels[].name as $l ([]; . + [$l]))
|
||||
}
|
||||
' <<< "$PR_JSON")"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Find Blocked/Stacked PRs in body
|
||||
id: pr_ids
|
||||
@ -160,7 +144,7 @@ jobs:
|
||||
|
||||
- name: Add 'blocked' Label is Missing
|
||||
id: label_blocked
|
||||
if: fromJSON(steps.pr_ids.outputs.prs).numBlocking > 0 && && !contains(fromJSON(env.JOB_DATA).prLabels, 'blocked') && !fromJSON(steps.blocking_data.outputs.all_merged)
|
||||
if: (fromJSON(steps.pr_ids.outputs.prs).numBlocking > 0) && !contains(fromJSON(env.JOB_DATA).prLabels, 'blocked') && !fromJSON(steps.blocking_data.outputs.all_merged)
|
||||
continue-on-error: true
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
2
.github/workflows/merge-blocking-pr.yml
vendored
2
.github/workflows/merge-blocking-pr.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
||||
|
||||
# a pr that was a `blocking:<id>` label was merged.
|
||||
# find the open pr's it was blocked by and trigger a refresh of their state
|
||||
if: github.event.pull_request.merged == true && contains( join( github.event.pull_request.labels.*.name, ',' ), "blocking" )
|
||||
if: github.event.pull_request.merged == true && contains( join( github.event.pull_request.labels.*.name, ',' ), 'blocking' )
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
Loading…
x
Reference in New Issue
Block a user