Skip to content

Commit

Permalink
Merge pull request #1555 from nerdalert/promote-job-qa
Browse files Browse the repository at this point in the history
Add qa-dev to promote for promotion validation
  • Loading branch information
mergify[bot] authored Oct 31, 2023
2 parents ed18f88 + 58db42f commit f12618a
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,62 @@ on:
workflow_dispatch:

jobs:
run-qa-dev:
# Dispatch the qa-dev workflow to validate main prior to promotion
runs-on: ubuntu-latest

env:
WAIT_INTERVAL: "60"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Capture current timestamp
run: |
current_time=$(date --utc +%Y-%m-%dT%H:%M:%S+00:00)
echo "current_time=${current_time}" >> "$GITHUB_ENV"
- name: Dispatch the qa-dev workflow
run: |
curl -X POST \
-H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{github.repository}}/actions/workflows/qa-dev.yml/dispatches" \
-d '{"ref": "main", "inputs": {"deployment_size": "small", "pr_or_branch": "main"}}'
echo "Triggered qa-dev Workflow."
- name: Wait for qa-dev workflow to complete
timeout-minutes: 30
run: |
check_status() {
runs=$(curl -s -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{github.repository}}/actions/workflows/deploy-qa-test.yml/runs?per_page=10")
latest_run=$(echo "$runs" | jq -r --arg timestamp "$current_time" \
'.workflow_runs[] | select(.created_at >= $timestamp) | .')
status=$(echo "$latest_run" | jq -r '.status')
conclusion=$(echo "$latest_run" | jq -r '.conclusion')
echo "Workflow status: $status, conclusion: $conclusion"
if [[ "$status" == "completed" && "$conclusion" == "success" ]]; then
return 0
elif [[ "$status" == "completed" && "$conclusion" != "success" ]]; then
echo "qa-dev workflow failed. For details, see https://github.com/nerdalert/apex-qa/actions/workflows/deploy-qa-test.yml"
exit 1
else
return 1
fi
}
while ! check_status; do
echo "Waiting for qa-dev workflow to complete..."
sleep "$WAIT_INTERVAL"
done
update-prod:
# Sync prod with the QA ref
name: Update Production Deployment
Expand Down

0 comments on commit f12618a

Please sign in to comment.