Unverified Commit 5ac55fc8 authored by Maia Teegarden's avatar Maia Teegarden Committed by GitHub

Check if target workflow is enabled before triggering front sync (#81432)

This change adds a check to ensure the front sync workflow is enabled
before attempting to trigger it. Previously, when the workflow was
disabled, the dispatch would fail and cause false alerts about
deployment test failures.

Now, if the workflow is disabled, the sync trigger is skipped with clear
logging. The on-call person should be aware that the workflow is
disabled and can manually rerun the sync once the workflow is
re-enabled.

I tested this by commenting out the tests and just running the check if
workflow is enabled step and it worked:
![CleanShot 2025-07-08 at 14 57
48](https://github.com/user-attachments/assets/e56e3e2c-61c2-4c56-935a-025d508d3fa2)
parent bbe2786b
...@@ -114,9 +114,38 @@ jobs: ...@@ -114,9 +114,38 @@ jobs:
run: gh auth status run: gh auth status
env: env:
GITHUB_TOKEN: ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }} GITHUB_TOKEN: ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
- uses: actions/github-script@v7
name: Check if target workflow is enabled
id: check-workflow-enabled
with:
retries: 3
retry-exempt-status-codes: 400,401,404
github-token: ${{ secrets.GH_UPDATE_NEXT_WORKFLOW_TRIGGER }}
result-encoding: string
script: |
try {
const response = await github.request(
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}",
{
owner: "vercel",
repo: "front",
workflow_id: "cron-update-next.yml",
}
);
const isEnabled = response.data.state === 'active';
console.info(`Target workflow state: ${response.data.state}`);
console.info(`Target workflow enabled: ${isEnabled}`);
return isEnabled ? 'true' : 'false';
} catch (error) {
console.error('Error checking workflow status:', error);
return 'false';
}
- uses: actions/github-script@v7 - uses: actions/github-script@v7
name: Trigger vercel/front sync name: Trigger vercel/front sync
id: trigger-front-sync id: trigger-front-sync
if: steps.check-workflow-enabled.outputs.result == 'true'
with: with:
retries: 3 retries: 3
retry-exempt-status-codes: 400,401,404 retry-exempt-status-codes: 400,401,404
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment