Daily Automatic Update 📝 #33
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
| ## 📂 .github/workflows/daily-update.yml | |
| # This must be the very first line (besides optional comments) | |
| name: Daily Automatic Update 📝 | |
| # Define when the workflow runs (e.g., every day at midnight UTC) | |
| on: | |
| schedule: | |
| # Run at 00:00 UTC daily | |
| - cron: '0 0 * * *' | |
| # Allows manual triggering from the GitHub UI | |
| workflow_dispatch: | |
| # A workflow is composed of one or more jobs | |
| jobs: | |
| update-file: | |
| # Use a standard runner environment | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| # Define the steps for this job | |
| steps: | |
| # Step 1: Checkout the repository code | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Step 2: Commit and push daily update | |
| - name: Commit and push daily update | |
| run: | | |
| # The following is the script from your original message | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create file if missing | |
| if [ ! -f daily_update.txt ]; then | |
| echo "File not found. Creating new daily_update.txt..." | |
| echo "Last updated: $(date)" > daily_update.txt | |
| fi | |
| # Update file with today's date | |
| echo "Last updated: $(date)" > daily_update.txt | |
| # Commit and push changes | |
| if [[ `git status --porcelain` ]]; then | |
| git add daily_update.txt | |
| git commit -m "⏰ Auto update: $(date)" | |
| # Use the simpler and modern way to push changes: | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi |