Skip to content

Commit e035d85

Browse files
committed
fix: add workflow input to override org secrets, detect old token
1 parent b805b12 commit e035d85

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

.github/workflows/test_cloudflare_purge.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
branches:
66
- test-cloudflare-purge
77
workflow_dispatch:
8+
inputs:
9+
cloudflare_auth_key:
10+
required: false
11+
type: string
12+
description: "Cloudflare API Token (overrides secret if provided)"
813

914
jobs:
1015
test_cloudflare_purge:
@@ -31,7 +36,46 @@ jobs:
3136
run: |
3237
# Get raw values first (before any processing)
3338
RAW_ZONE_ID="${{ secrets.CLOUDFLARE_ZONE }}"
34-
RAW_AUTH_TOKEN="${{ secrets.CLOUDFLARE_AUTH_KEY }}"
39+
40+
# Check if input token is provided (overrides secret)
41+
if [ -n "${{ inputs.cloudflare_auth_key }}" ]; then
42+
echo "✅ Using token from workflow input (overrides organization secret)"
43+
RAW_AUTH_TOKEN="${{ inputs.cloudflare_auth_key }}"
44+
else
45+
echo "Using token from secrets (may be from organization level)"
46+
RAW_AUTH_TOKEN="${{ secrets.CLOUDFLARE_AUTH_KEY }}"
47+
48+
# Check if we're reading the old token (from org secrets)
49+
if [ -n "$RAW_AUTH_TOKEN" ] && [ "${RAW_AUTH_TOKEN:0:3}" = "ObW" ]; then
50+
echo ""
51+
echo "⚠️ WARNING: Reading OLD token from organization secrets!"
52+
echo " Token starts with: ${RAW_AUTH_TOKEN:0:3}"
53+
echo " This is the OLD token that should be deleted."
54+
echo ""
55+
echo "The organization secret is overriding your repository secret."
56+
echo ""
57+
echo "SOLUTIONS:"
58+
echo "1. Ask an org admin to delete CLOUDFLARE_AUTH_KEY from org secrets"
59+
echo "2. OR use workflow_dispatch with input parameter to override:"
60+
echo " - Go to Actions → Test Cloudflare Cache Purge → Run workflow"
61+
echo " - Enter your NEW token (starting with 'fjx') in 'cloudflare_auth_key' field"
62+
echo " - This will override the org secret"
63+
echo ""
64+
echo "❌ Cannot proceed with old token. Please use workflow_dispatch with token input."
65+
exit 1
66+
fi
67+
fi
68+
69+
# Check if token is empty
70+
if [ -z "$RAW_AUTH_TOKEN" ]; then
71+
echo "❌ ERROR: CLOUDFLARE_AUTH_KEY is empty!"
72+
echo ""
73+
echo "SOLUTION: Use workflow_dispatch and provide the token as an input:"
74+
echo "1. Go to Actions → Test Cloudflare Cache Purge → Run workflow"
75+
echo "2. Enter your token in 'cloudflare_auth_key' field"
76+
echo "3. Click 'Run workflow'"
77+
exit 1
78+
fi
3579
3680
echo "=== Raw Secret Inspection ==="
3781
echo "Raw Zone ID length: ${#RAW_ZONE_ID}"

0 commit comments

Comments
 (0)