Create LICENSE #6
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: Update README with Vercel Deploy Status | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 * * * *' # Runs every hour | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Fetch Vercel deployment info | |
id: vercel | |
run: | | |
# Fetch the latest deployment information from Vercel API | |
response=$(curl -s -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" https://api.vercel.com/v6/deployments?projectId=prj_T1f4v51xSVNT4lz9Xjm9PBhsgiRg) | |
url=$(echo "$response" | jq -r '.deployments[0].url') | |
state=$(echo "$response" | jq -r '.deployments[0].state') | |
createdAt=$(echo "$response" | jq -r '.deployments[0].createdAt') | |
buildDate=$(date -d @$((createdAt/1000)) "+%Y-%m-%d %H:%M:%S") | |
# Output the values for use in the next steps | |
echo "preview_url=https://$url" >> $GITHUB_OUTPUT | |
echo "build_status=$state" >> $GITHUB_OUTPUT | |
echo "build_date=$buildDate" >> $GITHUB_OUTPUT | |
- name: Update README | |
run: | | |
# Replace placeholders in README with live data | |
sed -i "s|<!--vercel-preview-url-->|${{ steps.vercel.outputs.preview_url }}|g" README.md | |
sed -i "s|<!--vercel-build-status-->|${{ steps.vercel.outputs.build_status }}|g" README.md | |
sed -i "s|<!--vercel-build-date-->|${{ steps.vercel.outputs.build_date }}|g" README.md | |
- name: Configure Git | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "actions@github.com" | |
- name: Commit changes | |
run: | | |
git add README.md | |
git commit -m "[ACTIONS] Update README with build status" | |
- name: Push changes | |
run: | | |
git push | |
env: | |
# Use GitHub's authentication token to push changes | |
# This token is automatically provided by GitHub Actions and does not require setting up secrets | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |