如何自动更新个人资料自述文件

huangapple go评论75阅读模式
英文:

How to update the profile readme automatically

问题

我有一个位于以下网址的存储库:https://github.com/MateiMartin/MateiMartin/tree/main。

在这个存储库中,有一个README文件,我希望每30分钟自动更新,使用特定的.yaml文件。

不幸的是,我在完成这个任务时遇到了困难。

我尝试在运行部分使用git命令,但我一直遇到错误。能有人提供帮助来解决这个问题吗?

英文:

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?

答案1

得分: -1

以下是翻译好的内容:

试一试

您可以创建一个带有定时触发器的 GitHub Actions 工作流程。以下是如何设置的示例:

  1. 在您的存储库中,创建或编辑要自动更新的 README 文件。

  2. 在存储库中创建一个 .github/workflows/update-readme.yml 文件。此文件将包含工作流配置。

  3. 打开 update-readme.yml 文件并添加以下内容:

name: 每30分钟更新 README

on:
  schedule:
    - cron: "*/30 * * * *"

jobs:
  update-readme:
    runs-on: ubuntu-latest

    steps:
      - name: 检出存储库
        uses: actions/checkout@v2

      - name: 更新 README
        run: |
          # 在此处添加您的脚本或命令以自动生成 README 内容
          echo "此 README 在 $(date) 更新" > README.md          

      - name: 提交并推送更改
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add README.md
          git commit -m "更新 README" || echo "无更改可提交"
          git push          

  1. 在“更新 README”下的运行部分自定义您自己的脚本或命令,以生成或修改 README 文件的内容。

  2. 提交并推送 update-readme.yml 文件到您的存储库。

一旦工作流程设置完成,它将根据指定的 cron 计划每30分钟自动运行一次。

英文:

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 "action@github.com"
          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.

huangapple
  • 本文由 发表于 2023年7月4日 20:25:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612610.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定