Home > Software engineering >  Github action runs - but expected output not visible in repo
Github action runs - but expected output not visible in repo

Time:01-08

I recently tried to implement a Github action that should run daily and save a file to folder in the repository.

The jobs of this Github action run without errors but neither the folder nor the file show up in my repository.

You find the yml file here:

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

The idea is that it downloads the xlsx file everyday and stores it with a timestamp in the filename in a directory called "data" situated in the repo "github_actions".

The action runs without errors but directory and files don't show up there.

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

What am I missing here?

Thank you Bartleby

CodePudding user response:

This just creates a file inside the virtual machine. You need to commit and push the new changes also. For example, by using the Git Auto Commit Action:

name: Save RKI-Excel file Impfmonitoring

on:
  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'

To read more about GH Actions runners, visit the Runners section.

CodePudding user response:

Be sure to git add, git commit and git push:

This is what I do in my workflows in a pwsh step:

& git config --local user.email "[email protected]"
& 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
}
  • Related