githubgithub-actions

GH-Action green (success) but doesn't push changes


I have set up a dummy GitHub action which adds (stage) from a folder called data all its content.

   - name: Stage and commit data changes
      run: |
        git add data/ --verbose
        git commit -m "Automated commit of data files"|| echo "No changes to commit"
        git push origin main || echo "No changes to commit"

The sequence is successful, action workflow turns green.

However, when I navigate to that folder, the file is not there (wasn't staged nor pushed). It does exist in my local directory.

[v] Read and write permissions
Workflows have read and write permissions in the repository for all scopes.

Would really like to get some help, why it seems to run but doesn't capture it (add commit push)


Solution

  • I switched from Ubuntu to Windows, since I had an error related to a package i needed specifically for Linux (which I obviously cant install, as it runs remotely). It now works on a remote window machine, and I'm quite pleased.

    Problem had to do specifically with the cli package (R language)

      push-data:
        runs-on: windows-latest
        permissions:
          contents: write  
    .
    .
    .
     - name: Stage and commit data changes
          run: |
            git add . --verbose
            git commit -m "Re-ran scrape at $(date +'%Y-%m-%d')" || echo "No changes to commit"
            git push origin main || echo "No changes to commit"
    

    This now works!