Hands on!
First, we need to create a repository: https://github.com/new
Exploring jobs!
1 - Writing a simple workflow
01-hello-gha.yml
  on:
  workflow_dispatch:
name: 01-hello-gha
jobs:
  write-message:
    runs-on: ubuntu-latest
    steps:
      - name: print-message
        run: echo "Hello GitHub Actions! 🎉"
2 - Print message using R!
02-hello-r-world.yml
  on:
  workflow_dispatch:
name: 02-hello-r-world
jobs:
  write-message:
    runs-on: ubuntu-latest
    steps:
      - uses: r-lib/actions/setup-r@v2
      - name: print-message
        run: Rscript -e 'print("Hello R World!")'
        
3 - Run code from R script (only base packages)
03-run-r-script.yml
  on:
  workflow_dispatch:
name: 03-run-r-script
jobs:
  run-r-script:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: r-lib/actions/setup-r@v2
      - name: run-script
        run: Rscript scripts/03-r-script.R
        
scripts/03-r-script.R
4 - Run code using other packages
04-run-r-script-with-pkgs.yml
  on:
  workflow_dispatch:
name: 04-run-r-script-with-pkgs
jobs:
  run-r-script:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: r-lib/actions/setup-r@v2
        with: 
          use-public-rspm: true
      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          cache-version: 2
          packages:
            any::httr
            any::fs
      - name: run-script
        run: Rscript scripts/04-r-script.R        
scripts/04-r-script.R
library(httr)
library(fs)
print("Checking which files we have:")
dir_ls()
#  the URL 
url_download = "https://app.anm.gov.br/SIGBM/Publico/ClassificacaoNacionalDaBarragem/ExportarExcel"
# file name to save
file_name = paste0("sigbm_download_", Sys.Date(), ".xlsx")
print("Making a POST request and writing file on disk:")
POST(url_download, write_disk(file_name, overwrite = TRUE))
print("Checking which files we have:")
dir_ls()5 - Save results from code in the repository
05-saving-results.yml
  on:
  workflow_dispatch:
name: 05-saving-results
jobs:
  run-r-script:
    runs-on: ubuntu-latest
    env: 
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}    
    steps:
      - uses: actions/checkout@v3
      - uses: r-lib/actions/setup-r@v2
        with: 
          use-public-rspm: true
      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          cache-version: 2
          packages:
            any::httr
            any::fs
      - name: run-script
        run: Rscript scripts/04-r-script.R        
        
      - name: commit files
        run: |
          git config --local user.name "$GITHUB_ACTOR"
          git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
          git add -A
          git commit -m "Saving the results" || echo "no changes to commit"
          git push origin || echo "no changes to commit"
Exploring events!
6 - Schedule
Tip: CronTab Guru.
06-schedule.yml
  on:
  workflow_dispatch:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  "0/5 * * * *"
  
name: 06-event-schedule
jobs:
  run-r-script:
    runs-on: ubuntu-latest
    env: 
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}    
    steps:
      - uses: actions/checkout@v3
      - uses: r-lib/actions/setup-r@v2
        with: 
          use-public-rspm: true
      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          cache-version: 2
          packages:
            any::httr
            any::fs
      - name: run-script
        run: Rscript scripts/04-r-script.R        
        
      - name: commit files
        run: |
          git config --local user.name "$GITHUB_ACTOR"
          git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
          git add -A
          git commit -m "Saving the results" || echo "no changes to commit"
          git push origin || echo "no changes to commit"
7 - Changes on the code
The workflow run is triggered every time someone pushes a change to the repository or merges a pull request.
07-on-push.yml
  on:
  workflow_dispatch:
  push:
    branches:
      - main
      - master
name: 07-saving-results
jobs:
  run-r-script:
    runs-on: ubuntu-latest
    env: 
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}    
    steps:
      - uses: actions/checkout@v3
      - uses: r-lib/actions/setup-r@v2
        with: 
          use-public-rspm: true
      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          cache-version: 2
          packages:
            any::httr
            any::fs
      - name: run-script
        run: Rscript scripts/04-r-script.R        
        
      - name: commit files
        run: |
          git config --local user.name "$GITHUB_ACTOR"
          git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
          git add -A
          git commit -m "Saving the results" || echo "no changes to commit"
          git push origin || echo "no changes to commit"