GitHub Self-Updating Repository Demo #78
This file contains hidden or 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: GitHub Self-Updating Repository Demo | |
| on: | |
| # Schedule workflow to run daily at midnight | |
| schedule: | |
| - cron: "0 0 * * *" | |
| jobs: | |
| report: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository code | |
| # https://github.com/actions/checkout/tree/v3.0.2 | |
| uses: actions/checkout@v3 | |
| - name: Modify date and time | |
| id: modify | |
| run: | | |
| day_of_week=$(date +%u) | |
| if (( day_of_week == RANDOM % 7 + 1 )); then | |
| echo "Triggering update for day: $(date)" >> README.md | |
| cat README.md | |
| echo "run=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "run=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Push to repository | |
| if: ${{ steps.modify.outputs.run == 'true' }} | |
| run: | | |
| git config --global user.name "ZoreAnuj" | |
| git config --global user.email "zoreanuj@gmail.com" | |
| now=$(date) | |
| git add -A | |
| git commit -m "Auto Push on $now" | |
| git push |