Random Activity #68
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: Random Activity | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Runs daily at 6 AM UTC | |
| workflow_dispatch: | |
| jobs: | |
| random-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| with: | |
| persist-credentials: false # Important! Disable default token so we can use PAT | |
| - name: Generate random number (0-9) | |
| id: random | |
| run: echo "RANDOM_NUMBER=$((RANDOM % 10))" >> $GITHUB_ENV | |
| - name: Show random number | |
| run: echo "Random number was $RANDOM_NUMBER" | |
| - name: Maybe commit (if number is 0-2) | |
| if: ${{ env.RANDOM_NUMBER <= 2 }} | |
| run: | | |
| echo "Logging activity at $(date)" >> activity.txt | |
| git config --global user.name "Pratik Karbhal" | |
| git config --global user.email "pratikkarbhal@users.noreply.github.com" | |
| git add activity.txt | |
| git commit -m "Random activity $(date)" | |
| git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}.git | |
| git push origin HEAD:main |