Skip to content

Commit 0ab94da

Browse files
committed
improvements
1 parent 6bf6b4c commit 0ab94da

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

.github/workflows/wrangler.yaml

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,13 @@ jobs:
3737
- name: Install wrangler
3838
run: npm install -g wrangler
3939

40-
- name: Calculate secrets hash
41-
id: secrets-hash
42-
env:
43-
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
44-
run: |
45-
SECRETS_HASH=$(echo "$SECRETS_CONTEXT" | jq -r 'to_entries | map(select(.key | startswith("github_") | not) | select(.key != "CLOUDFLARE_API_TOKEN")) | sort_by(.key) | tostring' | sha256sum | cut -d' ' -f1)
46-
echo "hash=$SECRETS_HASH" >> $GITHUB_OUTPUT
47-
48-
- name: Restore secrets cache
49-
id: secrets-cache
50-
uses: actions/cache@v3
51-
with:
52-
path: .secrets-cache
53-
key: secrets-${{ steps.secrets-hash.outputs.hash }}
54-
55-
- name: Sync Secrets to Cloudflare
56-
if: steps.secrets-cache.outputs.cache-hit != 'true'
40+
- name: Sync All Secrets to Cloudflare
5741
env:
5842
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
5943
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
6044
run: |
61-
# Create a temporary file to mark cache
62-
mkdir -p .secrets-cache
63-
touch .secrets-cache/synced
64-
65-
# Get all secrets and process them in parallel
66-
echo "$SECRETS_CONTEXT" | jq -r 'to_entries | .[] | select(.key | startswith("github_") | not) | select(.key != "CLOUDFLARE_API_TOKEN") | @base64' | \
67-
parallel --jobs 10 'echo {} | base64 --decode | jq -r '"'"'.key,.value'"'" | {
68-
read -r secret
69-
read -r secret_value
45+
echo "$SECRETS_CONTEXT" | jq -r 'to_entries | .[] | select(.key | startswith("github_") | not) | select(.key != "CLOUDFLARE_API_TOKEN") | .key' | while read -r secret; do
46+
secret_value=$(jq -r --arg key "$secret" '.[$key]' <<< "$SECRETS_CONTEXT")
7047
7148
if [ -n "${{ steps.check-env.outputs.env_flag }}" ]; then
7249
echo "Setting $secret for environment ${{ steps.check-env.outputs.env_flag }}"
@@ -75,7 +52,7 @@ jobs:
7552
echo "Setting $secret for default environment"
7653
echo "$secret_value" | wrangler secret put "$secret"
7754
fi
78-
}'
55+
done
7956
8057
- name: Deploy
8158
uses: cloudflare/wrangler-action@v3

0 commit comments

Comments
 (0)