【问题标题】:Github Action is not Running on Push, only on scheduleGithub Action 不是在 Push 上运行,而是按计划运行
【发布时间】:2021-11-13 23:01:17
【问题描述】:

基于this article,我正在尝试生成一个在每次推送时运行的存储库,但也每 4 或 8 小时运行一次。如action history 所见,只有其中一个成功,并且仅在 Mac 机器上:

但我的目标是在 ubuntu-latest、windows-latest 和 macos-latest 上运行它以检查所有操作系统中的代码。最后一个目标是使计划推送的消息在 xxx 日期更新。这是我的最新代码9 月 23 日编辑,可以在 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"

现在它运行了,它实际上给了我一个勾号,但是 md 没有更新,在名为 commit results 的任务的运行中,我们可以看到以下错误

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

所以提交或推送不起作用,谢谢@krzysztof-madej,你发现了一个错误,那就是分支名称,但我仍然可以让结果更新自述文件,即使它运行顺利

【问题讨论】:

    标签: r r-markdown github-actions


    【解决方案1】:

    您的问题似乎与 git 相关,而不是 github 操作。 -a arg 将暂存所有文件,因此添加 README.md 似乎会使命令无效。尝试改变:

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

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

    【讨论】:

      【解决方案2】:

      目标:在ubuntu-latestwindows-latestmacos-latest 上运行它以检查所有操作系统中的代码:

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

      【讨论】:

      • 我试过了,但是r中的sf包在ubunto和macos的情况下都需要安装依赖
      • 你试过使用if语法吗?
      猜你喜欢
      • 1970-01-01
      • 2019-07-27
      • 2016-08-04
      • 2021-02-27
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      相关资源
      最近更新 更多