Github Action is not Running on Push, only on schedule

Viewed 429

Based on this article, I am trying to generate a repo that runs everytime y push, but also every 4 or 8 hours. as seen by the action history, only one of them was successful, and only on a Mac Machine:

But my goal is to run it on at ubuntu-latest, windows-latest and macos-latest to check the code in all OS. One final goal is to make it so that the message of the scheduled pushs is updated in xxx date. This is my latest code EDITED on sept 23 which can be seen in this repo:

name: render readme

on:
  push:
    paths:
      - README.Rmd
  schedule:
  - cron: 0 */4 * * *

jobs:
  render:
    runs-on: macOS-latest
    steps:
      - uses: actions/checkout@v2
      - uses: r-lib/actions/setup-r@v1
      - uses: r-lib/actions/setup-pandoc@v1
      - name: "[Custom block] [macOS] Install spatial libraries"
        if: runner.os == 'macOS'
        run: |
          # conflicts with gfortran from r-lib/actions when linking gcc
          rm '/usr/local/bin/gfortran'
          brew install pkg-config gdal proj geos
      - name: "[Stage] [macOS] Install libgit2"
        if: runner.os == 'macOS'
        run: brew install libgit2
      - name: Install packages
        run: Rscript -e 'install.packages(c("rmarkdown", "pacman", "rgeos"))'
      - name: install rgdal
        run: Rscript -e 'install.packages("rgdal", configure.args = c("--with-proj-lib=/usr/local/lib/", "--with-proj-include=/usr/local/include/"))'
      - name: Render README
        run: Rscript -e 'rmarkdown::render("README.Rmd", output_format = "md_document")'
      - name: Commit results
        run: |
          git add README.md man/figures/README-*
          git commit README.md -am 'Re-build README.md' || echo "No changes to commit"
          git push origin main || echo "No changes to commit"

Now it runs and it actually gives me a tick, but the md is not updated, within the runs in the task called commit results we can see the following error

Run git add README.md man/figures/README-*
  git add README.md man/figures/README-*
  git commit README.md -am 'Re-build README.md' || echo "No changes to commit"
  git push origin main || echo "No changes to commit"
  shell: /bin/bash -e {0}
  env:
    R_LIBS_USER: /Users/runner/work/_temp/Library
    TZ: UTC
    _R_CHECK_SYSTEM_CLOCK_: FALSE
    NOT_CRAN: true
fatal: paths 'README.md ...' with -a does not make sense
No changes to commit
Everything up-to-date

So the commit or push is not working, thank you @krzysztof-madej, you catched one mistake which was the branch name, but I still can make the results update the README, even though it runs smoothly

2 Answers

Objective: To run it on at ubuntu-latest, windows-latest and macos-latest to check the code in all OS:

runs-on: ${{ matrix.os }}
strategy:
  matrix:
    os:
      - ubuntu-latest
      - macos-latest
      - windows-latest

Your issue seems to be with git, not github actions. The -a arg will stage all files, so adding README.md seems to make the command invalid. Try changing:

git commit README.md -am 'Re-build README.md' || echo "No changes to commit"

to

git commit -am 'Re-build README.md' || echo "No changes to commit"

Related