collection Ingest Request for test-feb20 #170
Workflow file for this run
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: Post-Approval and Post-Merge Collection Promotion Checker | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| paths: | |
| - ingestion-data/staging/dataset-config/*.json | |
| - ingestion-data/staging/collections/*.json | |
| 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - 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 }} |