Avoid races in system_tests changing config by making the changes atomic #819
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Check Design Approved | |
on: | |
merge_group: | |
pull_request_target: | |
branches: [master, main] | |
types: [synchronize, opened, reopened, labeled, unlabeled] | |
permissions: | |
statuses: write | |
jobs: | |
check-design-approved: | |
name: Check if Design Approved | |
runs-on: ubuntu-4 | |
steps: | |
- name: Check if design approved and update status | |
run: | | |
set -euo pipefail | |
repo_url="${{ github.api_url }}/repos/$GITHUB_REPOSITORY" | |
commit_sha="${{ github.event.pull_request.head.sha || github.sha }}" | |
status_state="success" # default to success | |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then | |
design_approved='${{ contains(github.event.pull_request.labels.*.name, 'design-approved') }}' | |
after_next_version='${{ contains(github.event.pull_request.labels.*.name, 'after-next-version') }}' | |
status_state="pending" | |
if [[ "$design_approved" == "true" && "$after_next_version" != "true" ]]; then | |
status_state="success" | |
fi | |
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" \ | |
"${repo_url}/statuses/$commit_sha" \ | |
-d '{"context":"Design Approved Check","state":"'"$status_state"'"}' |