Skip to content

run-pipeline

run-pipeline #293

# Inspired by the template in the {targets} package
# https://github.com/ropensci/targets/blob/3b16f37ba5cdca710adbb81c2301f6b1d7432cfb/inst/templates/github_actions.yaml
name: run-pipeline
on:
schedule:
- cron: 0 0 * * *
push:
branches:
- main
- master
jobs:
targets:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
logger: pretty
log-directives: nix_installer=trace
backtrace: full
- name: Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build development environment
run: |
nix-build
- name: Compile website
run: |
nix-shell default.nix --run "Rscript -e 'targets::tar_make()'"
- name: Move html output
run: mv r-updates-fails.html output/r-updates-fails.html
- name: Identify files that the targets pipeline produced
run: git ls-files -mo --exclude=renv > .targets-files
- name: Create the runs branch if it does not already exist
if: steps.runs-exist.outcome != 'success'
run: git checkout --orphan targets-runs
- name: Put the worktree in the runs branch if the latter already exists
if: steps.runs-exist.outcome == 'success'
run: |
rm -r .git
mv .targets-runs/.git .
rm -r .targets-runs
- name: Upload latest run
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "[email protected]"
rm -r .gitignore .github/workflows
git add --all -- ':!renv'
for file in $(git ls-files -mo --exclude=renv)
do
git add --force $file
done
git commit -am "Run pipeline"
git push --force origin targets-runs
- name: Prepare failure artifact
if: failure()
run: rm -rf .git .github .targets-files .targets-runs
- name: Post failure artifact
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: .