如何将 devtools 包添加到 GitHub actions 中的 cron 作业

问题描述 投票:0回答:1

由于 DatawRappr 包仅在 Github 上可用...

devtools::install_github("munichrocker/DatawRappr")

如何将其添加到 cron 作业中?例如,这就是我现在拥有的:

   - name: Install packages
    uses: r-lib/actions/setup-r-dependencies@v2
    with:
      packages: |
        any::dplyr 
        any::janitor
        any::tidyr

并尝试过类似的事情

devtools::DatawRappr

  - name: Install DatawRappr package
    run: Rscript -e 'devtools::install_github("munichrocker/DatawRappr")'

  - name: Install other packages
    uses: r-lib/actions/setup-r-dependencies@v2
    with:
      packages: |
        any::dplyr 
        any::janitor
        any::tidyr

但我不知所措!

r github cron yaml github-actions
1个回答
0
投票

请参阅此示例存储库:https://github.com/the-mad-statter/action-run-r-script

使用 run-r-script.yaml:

on:
  push:
    branches: main

jobs:
  run-r-script:
    runs-on: ubuntu-latest
    steps:
      - name: Set up R
        uses: r-lib/actions/setup-r@v2

      - name: Install packages
        uses: r-lib/actions/setup-r-dependencies@v2
        with:
          packages: |
            any::dplyr 
            any::janitor
            any::tidyr
            
      - name: Install DatawRappr package
        run: |
          Rscript -e "pak::pkg_install('munichrocker/DatawRappr')"

      - name: Check out repository
        uses: actions/checkout@v4

      - name: Run script
        run: Rscript -e 'source("my_r_script.R")'

      - name: Commit results
        run: |
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Actions"
          git add output.txt
          git commit -m 'ran my_r_script.R' || echo "No changes to commit"
          git push origin || echo "No changes to commit"

如果您打算将工作流写回存储库,请记住将存储库设置 -> 操作 -> 常规 -> 工作流权限设置为“读写权限”。

© www.soinside.com 2019 - 2024. All rights reserved.