Skip to content

Commit

Permalink
ci: workflow chaining test
Browse files Browse the repository at this point in the history
  • Loading branch information
dshemetov committed Aug 31, 2023
1 parent 9a70a43 commit 9c91d14
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 42 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ name: ci

on:
workflow_dispatch: #get a button to trigger it by hand
push:
workflow_run:
workflows: ["Lint"]
type:
- complete

jobs:
build:
runs-on: ubuntu-20.04
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/document.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_run:
workflows: ["Style"]
type:
- complete
# paths:
# - "R/**"

name: Document

jobs:
document:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_branch }}

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: roxygen2

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE DESCRIPTION
git commit -m "Update documentation" || echo "No changes to commit"
git pull --ff-only
git push origin
13 changes: 8 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master, dev]
pull_request:
branches: [main, master, dev]
workflow_run:
workflows: ["Document"]
type:
- complete

name: lint
name: Lint

jobs:
lint:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"]
# paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"]

name: Style

Expand Down Expand Up @@ -65,44 +65,18 @@ jobs:
then
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git commit ${FILES_TO_COMMIT[*]} -m "style: styler (GHA)"
git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)"
git pull --ff-only
git push origin
else
echo "No changes to commit."
fi
document:
needs: style
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Trigger next workflow
if: success()
uses: peter-evans/repository-dispatch@v1
with:
use-public-rspm: true

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: roxygen2

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE DESCRIPTION
git commit -m "docs: update documentation (GHA)" || echo "No changes to commit"
git pull --ff-only
git push origin
token: ${{ secrets.REPO_GHA_PAT }}
repository: ${{ github.repository }}
event-type: style
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
3 changes: 2 additions & 1 deletion R/auth.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' Get the API key
#' @aliases get_auth_key_test
#'
#' Get the API key from the environment variable `DELPHI_EPIDATA_KEY` or
#' `getOption("delphi.epidata.key")`.
Expand All @@ -9,7 +10,7 @@
get_auth_key <- function() {
key <- Sys.getenv("DELPHI_EPIDATA_KEY", unset = "")
if (key != "") {
return(key)
return(key)
}

key <- getOption("delphi.epidata.key", default = "")
Expand Down

0 comments on commit 9c91d14

Please sign in to comment.