【问题标题】:Github action runs - but expected output not visible in repoGithub 操作运行 - 但预期输出在 repo 中不可见
【发布时间】:2023-01-08 02:20:17
【问题描述】:

我最近尝试实施一个 Github 操作,该操作应每天运行并将文件保存到存储库中的文件夹中。

此 Github 操作的作业运行无误,但文件夹和文件均未显示在我的存储库中。

您可以在此处找到 yml 文件:

https://github.com/analphabit/github_actions/blob/main/.github/workflows/save_rki_impfmonitoring_excel.yml

name: Save RKI-Excel file Impfmonitoring

on: [push] 
  #schedule:
  #  - cron: '0 0 * * *'

jobs:
  save-excel:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Create Directory
      run: |
        mkdir -p data
    - name: Download Excel File
      run: |
        python -c "from urllib.request import urlretrieve; urlretrieve('https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile', 'data/data.xlsx')"
    - name: Save Excel File
      run: |
        mv data/data.xlsx data/$(date +"%Y-%m-%d")-data.xlsx

这个想法是它每天下载 xlsx 文件并将其与文件名中的时间戳一起存储在 repo “github_actions” 中名为 “data” 的目录中。

该操作运行无误,但目录和文件不显示在那里。

https://github.com/analphabit/github_actions/actions/runs/3700392300

我在这里错过了什么?

谢谢 巴图比

【问题讨论】:

    标签: github github-actions


    【解决方案1】:

    请务必git addgit commitgit push

    这是我在 pwsh 步骤中的工作流程中所做的:

    & git config --local user.email "jesse.houwing@gmail.com"
    & git config --local user.name "Jesse Houwing"
    & git add .
    & git diff HEAD --exit-code | Out-Null
    if ($LASTEXITCODE -ne 0)
    {    
        & git commit -m "Regenerating renovate-data.json"
        & git push
    }
    

    【讨论】:

    • 你也可以从市场上使用一个动作......
    【解决方案2】:

    这只是在虚拟机中创建一个文件。您还需要提交并推送新的更改。例如,通过使用 Git Auto Commit 操作:

    name: Save RKI-Excel file Impfmonitoring
    
    on: [push]
      schedule:
        - cron: '0 0 * * *'
    
    jobs:
      save-excel:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v3
          - name: Create Directory
            run: |
              mkdir -p data
          - name: Download Excel File
            run: |
              python -c "from urllib.request import urlretrieve; urlretrieve('https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile', 'data/data.xlsx')"
          - name: Save Excel File
            run: |
              mv data/data.xlsx data/$(date +"%Y-%m-%d")-data.xlsx
    
          - uses: stefanzweifel/git-auto-commit-action@v4
            with:
              branch: main
              file_pattern: '*.xlsx'
    
    

    要了解有关 GH Actions 跑步者的更多信息,请访问 Runners 部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-13
      • 1970-01-01
      • 1970-01-01
      • 2021-02-19
      • 2014-05-26
      • 2022-06-14
      • 2020-11-17
      相关资源
      最近更新 更多