fix gh-actions
This commit is contained in:
73
.github/workflows/cloudflare-pages.yml
vendored
73
.github/workflows/cloudflare-pages.yml
vendored
@ -114,44 +114,45 @@ jobs:
|
|||||||
needs: deploy
|
needs: deploy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: success()
|
if: success()
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Wait for deployment to complete
|
|
||||||
run: sleep 3
|
|
||||||
|
|
||||||
- name: Cleanup old deployments
|
- name: Cleanup old deployments
|
||||||
run: |
|
run: |
|
||||||
# Get all deployments
|
curl -X PATCH \
|
||||||
DEPLOYMENTS=$(curl -s -X GET \
|
"https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/${{ secrets.CLOUDFLARE_PROJECT_NAME }} \
|
||||||
"https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/${{ secrets.CLOUDFLARE_PROJECT_NAME }}/deployments" \
|
|
||||||
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
|
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
|
||||||
-H "Content-Type: application/json")
|
-H "Content-Type: application/json")
|
||||||
|
-d "{ \"deployment_configs\": { \"production\": { \"deployment_retention\": ${{ env.KEEP_DEPLOYMENTS }} } } }"
|
||||||
# Extract deployment IDs (skip the latest N deployments)
|
# # Get all deployments
|
||||||
DEPLOYMENT_IDS=$(echo "$DEPLOYMENTS" | jq -r ".result | sort_by(.created_on) | reverse | .[${{ env.KEEP_DEPLOYMENTS }}:] | .[].id // empty")
|
# DEPLOYMENTS=$(curl -s -X GET \
|
||||||
|
# "https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/${{ secrets.CLOUDFLARE_PROJECT_NAME }}/deployments" \
|
||||||
if [ -z "$DEPLOYMENT_IDS" ]; then
|
# -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
|
||||||
echo "No old deployments to delete"
|
# -H "Content-Type: application/json")
|
||||||
exit 0
|
#
|
||||||
fi
|
# # Extract deployment IDs (skip the latest N deployments)
|
||||||
|
# DEPLOYMENT_IDS=$(echo "$DEPLOYMENTS" | jq -r ".result | sort_by(.created_on) | reverse | .[${{ env.KEEP_DEPLOYMENTS }}:] | .[].id // empty")
|
||||||
# Delete old deployments
|
#
|
||||||
for ID in $DEPLOYMENT_IDS; do
|
# if [ -z "$DEPLOYMENT_IDS" ]; then
|
||||||
echo "Deleting deployment: $ID"
|
# echo "No old deployments to delete"
|
||||||
RESPONSE=$(curl -s -X DELETE \
|
# exit 0
|
||||||
"https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/${{ secrets.CLOUDFLARE_PROJECT_NAME }}/deployments/$ID" \
|
# fi
|
||||||
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
|
#
|
||||||
-H "Content-Type: application/json")
|
# # Delete old deployments
|
||||||
|
# for ID in $DEPLOYMENT_IDS; do
|
||||||
SUCCESS=$(echo "$RESPONSE" | jq -r '.success')
|
# echo "Deleting deployment: $ID"
|
||||||
if [ "$SUCCESS" = "true" ]; then
|
# RESPONSE=$(curl -s -X DELETE \
|
||||||
echo "Successfully deleted deployment: $ID"
|
# "https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/${{ secrets.CLOUDFLARE_PROJECT_NAME }}/deployments/$ID" \
|
||||||
else
|
# -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
|
||||||
echo "Failed to delete deployment: $ID"
|
# -H "Content-Type: application/json")
|
||||||
echo "$RESPONSE" | jq .
|
#
|
||||||
fi
|
# SUCCESS=$(echo "$RESPONSE" | jq -r '.success')
|
||||||
|
# if [ "$SUCCESS" = "true" ]; then
|
||||||
sleep 1 # Rate limiting
|
# echo "Successfully deleted deployment: $ID"
|
||||||
done
|
# else
|
||||||
|
# echo "Failed to delete deployment: $ID"
|
||||||
echo "Cleanup completed!"
|
# echo "$RESPONSE" | jq .
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# sleep 1 # Rate limiting
|
||||||
|
# done
|
||||||
|
#
|
||||||
|
# echo "Cleanup completed!"
|
||||||
|
Reference in New Issue
Block a user