Skip to content

Commit acdd6f2

Browse files
authored
Merge pull request #70 from aicodingstack/develop
ci(workflow): improve deploy guard logic with better fallback handling
2 parents 60e965a + 027312e commit acdd6f2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ jobs:
3838
SHOULD_DEPLOY="true"
3939
REASON=""
4040
41+
if [[ "$ACTOR" == "dependabot[bot]" ]]; then
42+
SHOULD_DEPLOY="false"
43+
REASON="Dependabot-triggered workflows do not have access to repository secrets in this workflow."
44+
fi
45+
4146
if [[ "$EVENT_NAME" == "pull_request" ]]; then
4247
if [[ -n "$PR_HEAD_REPO" && "$PR_HEAD_REPO" != "$BASE_REPO" ]]; then
4348
SHOULD_DEPLOY="false"
4449
REASON="Fork pull requests do not have access to repository secrets in GitHub Actions."
4550
fi
46-
47-
if [[ "$ACTOR" == "dependabot[bot]" ]]; then
48-
SHOULD_DEPLOY="false"
49-
REASON="Dependabot pull requests do not have access to repository secrets in this workflow."
50-
fi
5151
fi
5252
5353
if [[ "$SHOULD_DEPLOY" == "true" ]]; then
5454
if [[ -z "$CF_API_TOKEN" || -z "$CF_ACCOUNT_ID" ]]; then
55-
echo "Missing required Cloudflare secrets. Please configure CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID in repository secrets."
56-
exit 1
55+
SHOULD_DEPLOY="false"
56+
REASON="Missing required Cloudflare secrets (CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID)."
5757
fi
5858
fi
5959
@@ -180,3 +180,7 @@ jobs:
180180
echo "- **Context:** ${{ steps.preview_meta.outputs.context_label }}" >> $GITHUB_STEP_SUMMARY
181181
echo "- **URL:** ${{ steps.preview_meta.outputs.preview_url }}" >> $GITHUB_STEP_SUMMARY
182182
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
183+
echo "- **Deploy:** ${{ steps.deploy_guard.outputs.should_deploy == 'true' && 'ran' || 'skipped' }}" >> $GITHUB_STEP_SUMMARY
184+
if [[ "${{ steps.deploy_guard.outputs.should_deploy }}" != "true" && -n "${{ steps.deploy_guard.outputs.reason }}" ]]; then
185+
echo "- **Skip reason:** ${{ steps.deploy_guard.outputs.reason }}" >> $GITHUB_STEP_SUMMARY
186+
fi

0 commit comments

Comments
 (0)