Skip to content

working on gh action #1

working on gh action

working on gh action #1

Workflow file for this run

name: Fetch Profile Image and Update README

Check failure on line 1 in .github/workflows/fetchprofile.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/fetchprofile.yml

Invalid workflow file

`schedule` accepts a list of one or more maps with the `cron` key set
on:
schedule:
workflow_dispatch:
- cron: "*/30 * * * *" # Runs every 30 minutes
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download profile image
run: |
curl -o profileimage.png https://projecteuler.net/profile/pepperonii.png
- name: Get current time
id: timestamp
run: |
echo "CURRENT_TIME=$(date '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Update README with profile image and timestamp
run: |
if [ -f "profileimage.png" ]; then
# Update README with the profile image path
sed -i 's|https://projecteuler.net/profile/pepperonii.png|./profileimage.png|' README.md
# Replace or add a "Last updated" timestamp at the end of the README
if grep -q "Last updated: " README.md; then
sed -i "s|_Last updated: .*_|_Last updated: ${CURRENT_TIME}_|" README.md
else
echo "_Last updated: ${CURRENT_TIME}_" >> README.md
fi
fi
env:
CURRENT_TIME: ${{ env.CURRENT_TIME }}
- name: Commit updated README
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add README.md
git commit -m "gh actions fetched profile image"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}