Skip to content

Update README with Bento Stats #5

Update README with Bento Stats

Update README with Bento Stats #5

Workflow file for this run

name: Update README with Bento Stats
on:
schedule:
- cron: "* * * * *"
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch Latest Bento Image URL
id: fetch_bento_url
run: |
API_URL="https://opbento.vercel.app/api/bento?n=Subhadeep%20Roy&i=https%3A%2F%2Fi.postimg.cc%2FhhFVCqM1%2Fsubha.jpg&g=subhadeeproy3902&x=mvp_Subha"
RESPONSE=$(curl -s "$API_URL")
echo "API Response: $RESPONSE" # Log the entire response
IMAGE_URL=$(echo $RESPONSE | jq -r '.url')
echo "Fetched Image URL: $IMAGE_URL"
echo "::set-output name=image_url::$IMAGE_URL"
- name: Check for URL Change
id: check_url_change
run: |
if [ -f last_image_url.txt ]; then
LAST_URL=$(cat last_image_url.txt)
echo "Last URL: $LAST_URL" # Log the last URL
echo "New URL: ${{ steps.fetch_bento_url.outputs.image_url }}" # Log the new URL
if [ "$LAST_URL" = "${{ steps.fetch_bento_url.outputs.image_url }}" ]; then
echo "No changes detected in the image URL."
echo "skip=true" >> $GITHUB_ENV
exit 0
fi
fi
echo "${{ steps.fetch_bento_url.outputs.image_url }}" > last_image_url.txt
echo "skip=false" >> $GITHUB_ENV
- name: Update README with New Image URL
if: env.skip != 'true'
run: |
IMAGE_URL=${{ steps.fetch_bento_url.outputs.image_url }}
README_FILE="README.md"
# Replace the existing URL in README.md
sed -i "s|!\[Bento GitHub Stats\](.*)|![Bento GitHub Stats]($IMAGE_URL)|g" "$README_FILE"
- name: Commit and Push Changes
if: env.skip != 'true'
run: |
git config --global user.email "subha9.5roy350@gmail.com"
git config --global user.name "Subhadeep"
git add README.md
git commit -m "Update README with latest Bento stats image"
git push