Skip to content

Commit

Permalink
Try using the statuses API instead
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Jul 10, 2024
1 parent ebb6446 commit a7f6e19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 41 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/merge-checks.yml

This file was deleted.

35 changes: 9 additions & 26 deletions .github/workflows/trigger-merge-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,24 @@ on:
types: [synchronize, opened, reopened, labeled, unlabeled]

permissions:
actions: write
checks: read
statuses: write

jobs:
check-design-approved:
name: Check Design Approved Status
runs-on: ubuntu-latest
steps:
- name: Run merge-checks workflow
if: ${{ contains(github.event.*.labels.*.name, 'design-approved') }}
- name: Check design approved status and update check
run: |
set -x pipefail
status_state="pending"
if ${{ contains(github.event.*.labels.*.name, 'design-approved') }}; then
status_state="success"
fi
curl -sSL --fail-with-body \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/merge-checks.yml/dispatches" \
-d '{"ref":"${{ github.head_ref }}"}'
- name: Update merge-checks workflow run
if: ${{ !contains(github.event.*.labels.*.name, 'design-approved') }}
run: |
set -x pipefail
if curl -sSL --fail-with-body \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/commits/{{ $github.event.pull_request.head.sha }}/check-runs" \
| jq -e '.check_runs | .[] | select(.name == "Design Approved Check")' >/dev/null
then
# The "design approved" check has previously run on this commit, so we need to reexecute it
curl -sSL --fail-with-body \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/merge-checks.yml/dispatches" \
-d '{"ref":"${{ github.head_ref }}"}'
fi
"https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/{{ $github.event.pull_request.head.sha }}" \
-d '{"context":"design-approved","state":"'"$status_state"'"}'

0 comments on commit a7f6e19

Please sign in to comment.