Updated build for - #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Netlify Deploy Log | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
log-netlify-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Monitor Netlify Deploy | |
run: | | |
echo "Waiting for Netlify deployment to start..." | |
while true; do | |
response=$(curl -s -H "Authorization: Bearer ${{ secrets.NETLIFY_ACCESS_TOKEN }}" https://api.netlify.com/api/v1/sites/${{ secrets.NETLIFY_SITE_ID }}/deploys?branch=main&per_page=1) | |
deploy_id=$(echo $response | jq -r '.[0].id') | |
status=$(echo $response | jq -r '.[0].state') | |
if [ "$status" != "null" ]; then | |
echo "Deployment started. Deploy ID: $deploy_id" | |
break | |
fi | |
sleep 5 | |
done | |
while true; do | |
response=$(curl -s -H "Authorization: Bearer ${{ secrets.NETLIFY_ACCESS_TOKEN }}" https://api.netlify.com/api/v1/sites/${{ secrets.NETLIFY_SITE_ID }}/deploys?branch=main&per_page=1) | |
status=$(echo $response | jq -r '.[0].state') | |
echo "Current status: $status" | |
if [ "$status" == "ready" ]; then | |
echo "Deployment completed successfully!" | |
break | |
elif [ "$status" == "error" ]; then | |
echo "Deployment failed!" | |
exit 1 | |
fi | |
# Get the latest log messages | |
log=$(curl -s -H "Authorization: Bearer ${{ secrets.NETLIFY_ACCESS_TOKEN }}" https://api.netlify.com/api/v1/deploys/$deploy_id/log) | |
echo "$log" | tail -n 5 | |
sleep 10 | |
done | |