.github/workflows/update-date.yaml #32
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
on: | |
schedule: | |
- cron: '30 5 1 * *' | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
name: Add next file | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create file and push | |
run: | | |
sudo apt update && sudo apt install -y ncal | |
next_hack_date=$(date -u +%Y-%m-$(ncal -h | awk '/Sa/ {print $(NF)}')) | |
last_hack_number=$(ls -1 _hacks | sort -r | head -n1 | sed 's/[^0-9]*//g') | |
next_hack_number=$(($last_hack_number+1)) | |
cat << EOF > _hacks/$next_hack_number.md | |
--- | |
hack_number: $next_hack_number | |
date: $next_hack_date | |
upcoming: true | |
--- | |
EOF | |
git config --global user.email "[email protected]" | |
git config --global user.name "date-bot" | |
git add . | |
git commit -m "Add hack number $next_hack_number on $next_hack_date" | |
git push origin main |