Search code examples
gitgithubyamlprofilereadme

How to update the profile readme automatically


I have a repository located at the following URL: https://github.com/MateiMartin/MateiMartin/tree/main.

Within this repository, there is a README file that I wish to update automatically every 30 minutes, utilizing a specific .yaml file. Unfortunately, I am encountering difficulties in achieving this task.

I have attempted to utilize git commands within the run section, but I consistently encounter errors. Could someone provide assistance in resolving this issue?


Solution

  • Try the following

    You can create a GitHub Actions workflow with a schedule trigger. Here's an example of how you can set it up:

    1. In your repository, create or edit the README file that you want to update automatically.

    2. Create a .github/workflows/update-readme.yml file in the repository. This file will contain the workflow configuration.

    3. Open the update-readme.yml file and add the following content:

    name: Update README every 30 minutes
    
    on:
      schedule:
        - cron: "*/30 * * * *"
    
    jobs:
      update-readme:
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout repository
            uses: actions/checkout@v2
    
          - name: Update README
            run: |
              # Add your script or commands here to automatically generate the README content
              echo "This README was updated at $(date)" > README.md
    
          - name: Commit and push changes
            run: |
              git config --local user.email "[email protected]"
              git config --local user.name "GitHub Action"
              git add README.md
              git commit -m "Update README" || echo "No changes to commit"
              git push
    
    
    1. Customize the run section under "Update README" with your own script or commands that generate or modify the content of the README file.

    2. Commit and push the update-readme.yml file to your repository.

    Once the workflow is set up, it will run automatically every 30 minutes based on the specified cron schedule.