diff --git a/.github/workflows/merge-checks.yml b/.github/workflows/merge-checks.yml deleted file mode 100644 index 6c7fac2cb6..0000000000 --- a/.github/workflows/merge-checks.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Merge Checks - -on: workflow_dispatch - -jobs: - design-approved-check: - name: Design Approved Check - runs-on: ubuntu-latest - steps: - - name: Missing design-approved label - if: ${{ !contains(github.event.*.labels.*.name, 'design-approved') }} - run: | - echo "Pull request is missing the 'design-approved' label" - echo "This workflow fails so that the pull request cannot be merged" - exit 1 diff --git a/.github/workflows/trigger-merge-checks.yml b/.github/workflows/trigger-merge-checks.yml index 23ca2cad8e..3e5814d07c 100644 --- a/.github/workflows/trigger-merge-checks.yml +++ b/.github/workflows/trigger-merge-checks.yml @@ -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"'"}'