Skip to content

feat(workflow-dispatcher): Always run jobs on main #9

feat(workflow-dispatcher): Always run jobs on main

feat(workflow-dispatcher): Always run jobs on main #9

on:
workflow_call:
inputs:
skip:
required: false
type: string
default: ''
main_branches:
required: false
type: string
default: 'main,master'
event_name:
required: true
type: string
run_id:
required: true
type: string
rcmdcheck_args:
required: false
type: string
default: 'c("--no-manual", "--as-cran", "--no-tests")'
schemas:
required: false
type: string
backend_exclude:
required: false
type: string
check_postgres_logs:
required: false
type: boolean
default: true
jobs:
# To give granular control of when workflows should execute, we determine which "categories" of files has changed
trigger:
name: ⚙️ Determine downstream workflow triggers
runs-on: ubuntu-latest
outputs:

Check failure on line 44 in .github/workflows/workflow-dispatcher.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/workflow-dispatcher.yaml

Invalid workflow file

You have an error in your yaml syntax on line 44
on_main_branch: ${{ steps.main_branch_affected.outputs.on_main_branch }}
main_branch_affected: ${{ steps.main_branch_affected.outputs.main_branch_affected }}
branch_name: ${{ steps.branch_name.outputs.branch_name }}
cache_version: ${{ steps.cache_version.outputs.cache_version }}
lint: ${{
!contains(inputs.skip, 'lint') &&
(
inputs.event_name == 'workflow_dispatch' ||
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
(
steps.changed-files-yaml.outputs.R_any_changed == 'true' ||
steps.changed-files-yaml.outputs.test_any_changed == 'true' ||
steps.changed-files-yaml.outputs.man_any_changed == 'true' ||
steps.changed-files-yaml.outputs.vignette_any_changed == 'true'
)
)
}}
spell-checker: ${{
!contains(inputs.skip, 'spell-checker') &&
(
inputs.event_name == 'workflow_dispatch' ||
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
(
steps.changed-files-yaml.outputs.description_any_changed == 'true' ||
steps.changed-files-yaml.outputs.man_any_changed == 'true' ||
steps.changed-files-yaml.outputs.vignette_any_changed == 'true'
)
)
}}
R-CMD-check: ${{
!contains(inputs.skip, 'R-CMD-check') &&
(
inputs.event_name == 'workflow_dispatch' ||
inputs.event_name == 'release' ||
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
(
steps.main_branch_affected.outputs.main_branch_affected == 'true' &&
(
steps.changed-files-yaml.outputs.R_any_changed == 'true' ||
steps.changed-files-yaml.outputs.test_any_changed == 'true' ||
steps.changed-files-yaml.outputs.description_any_changed == 'true' ||
steps.changed-files-yaml.outputs.man_any_changed == 'true' ||
steps.changed-files-yaml.outputs.vignette_any_changed == 'true'
)
)
)
}}
code-coverage: ${{
!contains(inputs.skip, 'code-coverage') &&
(
inputs.event_name == 'workflow_dispatch' ||
inputs.event_name == 'release' ||
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
(
steps.main_branch_affected.outputs.main_branch_affected == 'true' &&
(
steps.changed-files-yaml.outputs.R_any_changed == 'true' ||
steps.changed-files-yaml.outputs.test_any_changed == 'true' ||
steps.changed-files-yaml.outputs.description_any_changed == 'true'
)
)
)
}}
document: ${{
!contains(inputs.skip, 'document') &&
(
inputs.event_name == 'workflow_dispatch' ||
(
inputs.event_name != 'release' &&
(
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
steps.changed-files-yaml.outputs.R_any_changed == 'true' ||
steps.changed-files-yaml.outputs.description_any_changed == 'true'
)
)
)
}}
render-readme: ${{
!contains(inputs.skip, 'render-readme') &&
(
inputs.event_name == 'workflow_dispatch' ||
(
inputs.event_name != 'release' &&
(
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
needs.trigger.outputs.readme_any_changed == 'true'
)
)
)
}}
pkgdown: ${{
!contains(inputs.skip, 'pkgdown') &&
(
inputs.event_name == 'workflow_dispatch' ||
inputs.event_name == 'release' ||
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
(
steps.main_branch_affected.outputs.main_branch_affected == 'true' &&
(
steps.changed-files-yaml.outputs.R_any_changed == 'true' ||
steps.changed-files-yaml.outputs.description_any_changed == 'true' ||
steps.changed-files-yaml.outputs.man_any_changed == 'true' ||
steps.changed-files-yaml.outputs.vignette_any_changed == 'true'
)
)
)
}}
update-lockfile: ${{
!contains(inputs.skip, 'update-lockfile') &&
(
inputs.event_name == 'workflow_dispatch' ||
(
inputs.event_name != 'release' &&
(
steps.main_branch_affected.outputs.on_main_branch == 'true' ||
(
steps.main_branch_affected.outputs.main_branch_affected == 'true' &&
(
steps.changed-files-yaml.outputs.R_any_changed == 'true' ||
steps.changed-files-yaml.outputs.test_any_changed == 'true' ||
steps.changed-files-yaml.outputs.description_any_changed == 'true'
)
)
)
)
)
}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changes to R/, tests/, man/, vignettes/, README.Rmd and DESCRIPTION
id: changed-files-yaml
uses: tj-actions/changed-files@v41
with:
files_yaml: |
R:
- R/**
test:
- tests/**
man:
- man/**
vignette:
- vignettes/**
readme:
- README.md
- README.Rmd
- .github/templates/README_template.Rmd
description:
- DESCRIPTION
- name: Determine branch name
id: branch_name
shell: bash
run: |
echo "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Determine main branch involvement
id: main_branch_affected
shell: bash
run: |
if [ "${{ inputs.event_name }}" == "pull_request" ] && [[ "${{ inputs.main_branches }}" == *"$GITHUB_BASE_REF"* ]]; then
# Pull request event to a main branch
echo "main_branch_affected=true" >> $GITHUB_OUTPUT
echo "on_main_branch=false" >> $GITHUB_OUTPUT
elif [ "${{ inputs.event_name }}" != "pull_request" ] && [[ "${{ inputs.main_branches }}" == *"$GITHUB_REF_NAME"* ]]; then
# Non pull request event to a main branch
echo "main_branch_affected=true" >> $GITHUB_OUTPUT
echo "on_main_branch=true" >> $GITHUB_OUTPUT
else
# All other cases
echo "main_branch_affected=false" >> $GITHUB_OUTPUT
echo "on_main_branch=false" >> $GITHUB_OUTPUT
fi
- name: Invalidate cache on workflow_dispatch
id: cache_version
shell: bash
run: |
if [ "${{ inputs.event_name }}" == "workflow_dispatch" ] ; then
echo "cache_version=0" >> $GITHUB_OUTPUT
else
echo "cache_version=1" >> $GITHUB_OUTPUT
fi
- name: Report triggers
run: |
echo "R/ directory changes: ${{ steps.changed-files-yaml.outputs.R_any_changed }}"
echo "tests/ directory changes: ${{ steps.changed-files-yaml.outputs.test_any_changed }}"
echo "man/ directory changes: ${{ steps.changed-files-yaml.outputs.man_any_changed }}"
echo "vignettes/ directory changes: ${{ steps.changed-files-yaml.outputs.vignette_any_changed }}"
echo "README.Rmd changed: ${{ steps.changed-files-yaml.outputs.readme_any_changed }}"
echo "DESCRIPTION changed: ${{ steps.changed-files-yaml.outputs.description_any_changed }}"
echo "main branch affected: ${{ steps.main_branch_affected.outputs.main_branch_affected }}"
echo "branch name: ${{ steps.branch_name.outputs.branch_name }}"
echo "cache_version: ${{ steps.cache_version.outputs.cache_version }}"
inspect-trigger-output:
needs: trigger
name: 🐞 Inspect trigger output
runs-on: ubuntu-latest
steps:
- run: |
echo "main_branch_affected: ${{ needs.trigger.outputs.main_branch_affected }}"
echo "branch_name: ${{ needs.trigger.outputs.branch_name }}"
echo "cache_version: ${{ needs.trigger.outputs.cache_version }}"
echo "lint: ${{ needs.trigger.outputs.lint }}"
echo "spell-checker: ${{ needs.trigger.outputs.spell-checker }}"
echo "R-CMD-check: ${{ needs.trigger.outputs.R-CMD-check }}"
echo "code-coverage: ${{ needs.trigger.outputs.code-coverage }}"
echo "document: ${{ needs.trigger.outputs.document }}"
echo "render-readme: ${{ needs.trigger.outputs.render-readme }}"
echo "pkgdown: ${{ needs.trigger.outputs.pkgdown }}"
echo "update-lockfile: ${{ needs.trigger.outputs.update-lockfile }}"
update-lockfile:
needs: trigger
uses: ./.github/workflows/update-lockfile.yaml
if: ${{ needs.trigger.outputs.update-lockfile == 'true' }}
with:
cache_version: ${{ needs.trigger.outputs.cache_version }}
branch_name: ${{ needs.trigger.outputs.branch_name }}
secrets: inherit
concurrency:
group: update-lockfile-${{ needs.trigger.outputs.branch_name }}
cancel-in-progress: true
document:
needs: [trigger, update-lockfile]
uses: ./.github/workflows/document.yaml
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.document == 'true' }}
with:
branch_name: ${{ needs.trigger.outputs.branch_name }}
secrets: inherit
concurrency:
group: document-${{ needs.trigger.outputs.branch_name }}
cancel-in-progress: true
render-readme:
needs: [trigger, update-lockfile]
uses: ./.github/workflows/render-readme.yaml
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.render-readme == 'true' }}
with:
branch_name: ${{ needs.trigger.outputs.branch_name }}
secrets: inherit
concurrency:
group: render-readme-${{ needs.trigger.outputs.branch_name }}
cancel-in-progress: true
lint:
needs: [trigger, update-lockfile, document, render-readme]
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.lint == 'true' }}
uses: ./.github/workflows/lint.yaml
spell-checker:
needs: [trigger, update-lockfile, document, render-readme]
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.spell-checker == 'true' }}
uses: ./.github/workflows/spell-checker.yaml
secrets: inherit
R-CMD-check:
needs: [trigger, update-lockfile, document, render-readme]
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.R-CMD-check == 'true' }}
uses: ./.github/workflows/R-CMD-check.yaml
with:
rcmdcheck_args: ${{ inputs.rcmdcheck_args }}
cache_version: ${{ needs.trigger.outputs.cache_version }}
secrets: inherit
concurrency:
group: R-CMD-check-${{ needs.trigger.outputs.branch_name }}
cancel-in-progress: true
code-coverage:
needs: [trigger, update-lockfile, document, render-readme]
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.code-coverage == 'true' }}
uses: ./.github/workflows/code-coverage.yaml
with:
cache_version: ${{ needs.trigger.outputs.cache_version }}
schemas: ${{ inputs.schemas }}
backend_exclude: ${{ inputs.backend_exclude }}
check_postgres_logs: ${{ inputs.check_postgres_logs }}
secrets: inherit
concurrency:
group: code-coverage-${{ needs.trigger.outputs.branch_name }}
cancel-in-progress: true
pkgdown:
needs: [trigger, update-lockfile, document, render-readme]
if: ${{ always() && !failure() && !cancelled() && needs.trigger.outputs.pkgdown == 'true' }}
uses: ./.github/workflows/pkgdown.yaml
with:
event_name: ${{ inputs.event_name }}
run_id: ${{ inputs.run_id }}
secrets: inherit
concurrency:
group: pkgdown-${{ needs.trigger.outputs.branch_name }}${{ github.event_name == 'release' && '-release' || '' }}
cancel-in-progress: true