GitHub Actions is “a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline.”
https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions
You can automate the running of certain scripts, to do anything from
Windows and Linux virtual machines:
macOS virtual machines:
yaml
(or yml
) filename: my_workflow
on:
workflow_dispatch:
push:
branches: [main, my_feature_branch]
schedule:
- cron: "30 9,17 * * 1-5"
workflow_dispatch
push
schedule
runs-on
; usually ubuntu-latest
jobs:
my-super-neat-job:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN}}
MY_SECRET_PASSWORD: ${{ secrets.MIKES_PW }}
run
), or call others that have been developed (uses
)
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install packages
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
any::dplyr
any::lubridate
The next few are usually where all of the fun stuff happens
- name: My first R script
run: Rscript "do_the_thing.R"
- name: My next R commands
run: |
my_addition <- 2 + 2
shell: Rscript {0}
- name: Show my variable
run: my_addition
shell: Rscript {0}
We usually want to do something with the result. If we want to save things, we need to commit it to the repository.
- name: Commit files
run: |
git config --local user.name actions-user
git config --local user.email "[email protected]"
git add .
git commit -am "GH ACTION did something on $(date)"
git push origin main
Workflow level
on:
workflow_dispatch:
permissions:
contents: write
Job level
job:
my_awesome_job:
permissions:
contents:
write
env:
SUPERSECRET: ${{ secrets.my_saved_secret_on_GH }}