Skip to content

Commit 8da0c90

Browse files
shantanu patilclaude
authored andcommitted
Fix secrets context in workflow if-conditions across all workflows
GitHub Actions does not allow secrets in if-expressions. Use env vars with shell-level empty check instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e982ffb commit 8da0c90

6 files changed

Lines changed: 28 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ jobs:
7272
runs-on: ubuntu-latest
7373
steps:
7474
- name: Notify Slack on failure
75-
if: ${{ secrets.SLACK_WEBHOOK_URL != '' }}
75+
env:
76+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
7677
run: |
77-
curl -s -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
78+
[ -z "$SLACK_WEBHOOK_URL" ] && exit 0
79+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
7880
-H 'Content-Type: application/json' \
7981
-d '{
8082
"blocks": [

.github/workflows/deploy-api.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ jobs:
9696
echo "URL: $URL" >> $GITHUB_STEP_SUMMARY
9797
9898
- name: Notify Slack on failure
99-
if: failure() && secrets.SLACK_WEBHOOK_URL != ''
99+
if: failure()
100+
env:
101+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
100102
run: |
101-
curl -s -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
103+
[ -z "$SLACK_WEBHOOK_URL" ] && exit 0
104+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
102105
-H 'Content-Type: application/json' \
103106
-d '{
104107
"blocks": [

.github/workflows/deploy-preview.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ jobs:
186186
runs-on: ubuntu-latest
187187
steps:
188188
- name: Notify Slack on failure
189-
if: ${{ secrets.SLACK_WEBHOOK_URL != '' }}
189+
env:
190+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
190191
run: |
191-
curl -s -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
192+
[ -z "$SLACK_WEBHOOK_URL" ] && exit 0
193+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
192194
-H 'Content-Type: application/json' \
193195
-d '{
194196
"blocks": [

.github/workflows/deploy-web.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ jobs:
103103
echo "URL: $URL" >> $GITHUB_STEP_SUMMARY
104104
105105
- name: Notify Slack on failure
106-
if: failure() && secrets.SLACK_WEBHOOK_URL != ''
106+
if: failure()
107+
env:
108+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
107109
run: |
108-
curl -s -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
110+
[ -z "$SLACK_WEBHOOK_URL" ] && exit 0
111+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
109112
-H 'Content-Type: application/json' \
110113
-d '{
111114
"blocks": [

.github/workflows/infra-apply.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ jobs:
5252
echo "Applied by: @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
5353
5454
- name: Notify Slack on failure
55-
if: failure() && secrets.SLACK_WEBHOOK_URL != ''
55+
if: failure()
56+
env:
57+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
5658
run: |
57-
curl -s -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
59+
[ -z "$SLACK_WEBHOOK_URL" ] && exit 0
60+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
5861
-H 'Content-Type: application/json' \
5962
-d '{
6063
"blocks": [

.github/workflows/infra-plan.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ jobs:
108108
}
109109
110110
- name: Notify Slack on failure
111-
if: failure() && secrets.SLACK_WEBHOOK_URL != ''
111+
if: failure()
112+
env:
113+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
112114
run: |
113-
curl -s -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
115+
[ -z "$SLACK_WEBHOOK_URL" ] && exit 0
116+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
114117
-H 'Content-Type: application/json' \
115118
-d '{
116119
"blocks": [

0 commit comments

Comments
 (0)