Skip to content

check vercel

check vercel #18

Workflow file for this run

name: Trigger Vercel Deployment on #deploy Commit
on:
push:
branches:
- main
jobs:
trigger-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch full history to get all commits
- name: Check commit messages for #deploy
id: check_deploy
run: |
echo "Checking commits for #deploy keyword..."
commits=$(git log --format=%B ${{ github.event.before }}..${{ github.sha }})
echo "Commit messages in push:"
echo "$commits"
if echo "$commits" | grep -q "#deploy"; then
echo "deploy=true" >> $GITHUB_OUTPUT
else
echo "deploy=false" >> $GITHUB_OUTPUT
fi
- name: Trigger Vercel Deployment
if: steps.check_deploy.outputs.deploy == 'true'
run: |
echo "Triggering Vercel deployment..."
response=$(curl -s -w "%{http_code}" -X POST "${{ secrets.VERCEL_DEPLOY_HOOK_URL }}" -o response.txt)
body=$(cat response.txt)
echo "Response body:"
echo "$body"
echo "HTTP status code: $response"
if [[ "$response" -lt 200 || "$response" -ge 300 ]]; then
echo "Deployment trigger failed with HTTP status $response"
exit 1
fi
# Optionally check if response contains expected keys
if ! echo "$body" | grep -q '"job"'; then
echo "Unexpected response body, deployment might not have triggered."
exit 1
fi
- name: Get commit author
run: |
AUTHOR=$(git log -1 --pretty=format:'%an <%ae>')
echo "author=$AUTHOR" >> "$GITHUB_OUTPUT"
- name: Debug Author Output
run: |
echo "Captured Author: ${{ steps.commit_author.outputs.author }}"