Skip to content

Ingest Request for blizzard-era5-mslp #83

Ingest Request for blizzard-era5-mslp

Ingest Request for blizzard-era5-mslp #83

name: Post-Approval and Post-Merge Collection Promotion Checker
on:
pull_request:
types:
- closed
permissions:
actions: write
contents: read
jobs:
check-conditions:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Print PR number
run: |
echo "Processing PR #${{ github.event.pull_request.number }}"
- name: Check for PR approval
run: |
APPROVALS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews --jq '[.[] | select(.state == "APPROVED")] | length')
if [ "$APPROVALS" -gt 0 ]; then
echo "PR was approved. Running promotion workflow."
echo "APPROVED=true" >> $GITHUB_ENV
else
echo "PR was NOT approved. Exiting."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if pr.yml succeeded
id: check_pr_workflow
run: |
WORKFLOW_STATUS=$(gh run list --repo ${{ github.repository }} --branch ${{ github.event.pull_request.head.ref }} --workflow "pr.yml" --json status --jq '.[0].status // "not found"')
echo "Previous workflow (pr.yml) status: $WORKFLOW_STATUS"
if [ "$WORKFLOW_STATUS" != "completed" ]; then
echo "Previous workflow (pr.yml) did not complete successfully. Exiting..."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
trigger-promotion-workflow:
runs-on: ubuntu-latest
needs: check-conditions
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Workflow Run ID Artifact
run: |
gh run download \
--repo ${{ github.repository }} \
--name run-id-${{ github.event.pull_request.number }} \
--dir ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Read Run ID
id: read-run-id
run: |
cat run_id.txt
RUN_ID=$(cat run_id.txt)
echo "RUN_ID=$RUN_ID" >> $GITHUB_ENV
echo $RUN_ID
- name: Trigger Promotion workflow
run: |
gh workflow list
gh workflow run promote.yml --repo ${{ github.repository }} -f trigger_token=${{ secrets.WORKFLOW_TRIGGER_TOKEN }} -f pr_number=${{ github.event.pull_request.number }} -f run_id=$RUN_ID
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}