Skip to content

.github/workflows/profile-banner.yml #1886

.github/workflows/profile-banner.yml

.github/workflows/profile-banner.yml #1886

on:
schedule:
- cron: '0 3,9,15,21 * * *'
workflow_dispatch:
jobs:
dynamic-img-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine which image to use
id: determine-image
run: |
hour=$(date +%H)
if [ $hour -ge 3 ] && [ $hour -lt 9 ]; then
echo "image=1.png" >> $GITHUB_ENV
elif [ $hour -ge 9 ] && [ $hour -lt 15 ]; then
echo "image=2.png" >> $GITHUB_ENV
elif [ $hour -ge 15 ] && [ $hour -lt 21 ]; then
echo "image=3.png" >> $GITHUB_ENV
else
echo "image=4.png" >> $GITHUB_ENV
fi
- name: Copy image to root and rename
run: cp -f images/${{ env.image }} main.png
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add main.png
git commit -m "Update main.png with ${{ env.image }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}