Skip to content

export abn output to other format(s) #443

export abn output to other format(s)

export abn output to other format(s) #443

# Workflow triggered when we have a new release candidate
# This action is adapted from https://github.com/t4d-gmbh/stubbed_versioning
name: On Label pckgdown build
on:
pull_request:
types: [ labeled ]
env:
LABEL_CHECK: 'pkgdown::check'
LABEL_SUCCESS: 'pkgdown::passed'
LABEL_FAILURE: 'pkgdown::failed'
DOC_LOC: "./docs"
jobs:
set_target:
if: ${{ github.event.label.name == 'pkgdown::check' }}
runs-on: ubuntu-latest
outputs:
label: ${{ steps.set_label.outputs.label }}
steps:
- id: set_label
run: |
echo "label=${{ env.LABEL_CHECK }}" >> "$GITHUB_OUTPUT"
check_label_exist:
needs:
- set_target
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
permissions:
pull-requests: write
contents: write
steps:
- name: Assert labels ${{ env.LABEL_CHECK }} is defined
run: |
gh label create ${{ env.LABEL_CHECK }} --repo ${{ env.OWNER }}/${{ env.REPO }}
continue-on-error: true # make sure the next steps run also on failure
- name: Assert labels ${{ env.LABEL_SUCCESS }} is defined
run: |
gh label create ${{ env.LABEL_SUCCESS }} --repo ${{ env.OWNER }}/${{ env.REPO }}
continue-on-error: true # make sure the next steps run also on failure
- name: Assert labels ${{ env.LABEL_FAILURE }} is defined
run: |
gh label create ${{ env.LABEL_FAILURE }} --repo ${{ env.OWNER }}/${{ env.REPO }}
continue-on-error: true # make sure the next steps run also on failure
pkgdown_build:
runs-on: ubuntu-latest
needs:
- set_target
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
id-token: write
pages: write
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website
- name: Build site
run: |
pkgdown::build_site_github_pages(dest_dir= "${{ env.DOC_LOC }}", new_process = FALSE, install = FALSE)
shell: Rscript {0}
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload pkgdown artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.DOC_LOC }}
report_pkgdown_build:
if: ${{ (success() || failure()) }}
needs:
- pkgdown_build
- check_label_exist
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
steps:
- uses: actions/checkout@v4
- name: Check if on demand tasks succeeded
run: |
gh pr edit ${{ env.EVENT }} --remove-label ${{ env.LABEL_CHECK }} --repo ${{ env.OWNER }}/${{ env.REPO }}
if [ ${{ needs.pkgdown_build.result }} == "success" ]; then
gh pr edit ${{ env.EVENT }} --remove-label ${{ env.LABEL_FAILURE }} --repo ${{ env.OWNER }}/${{ env.REPO }}
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_SUCCESS }} --repo ${{ env.OWNER }}/${{ env.REPO }}
echo "### ${{ github.event.label.url }} passed! :rocket:" >> $GITHUB_STEP_SUMMARY
exit 0;
elif [ ${{ needs.pkgdown_build.result }} == "failure" ]; then
gh pr edit ${{ env.EVENT }} --remove-label ${{ env.LABEL_SUCCESS }} --repo ${{ env.OWNER }}/${{ env.REPO }}
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_FAILURE }} --repo ${{ env.OWNER }}/${{ env.REPO }}
echo "### ${{ github.event.label.url }} failed!" >> $GITHUB_STEP_SUMMARY
exit 1;
else
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_CHECK }} --repo ${{ env.OWNER }}/${{ env.REPO }}
echo "On demand task outcome was ${{ steps.some_task.outcome }}";
fi
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event.number }} # This is either the issue or pr
record_passed_label:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
permissions:
contents: write
pull-requests: write
repository-projects: write
outputs:
passed: ${{ steps.passed.outputs.PASSED}}
steps:
- name: Check if the pull request is labeled with ${{ env.LABEL_SUCCESS }} # 2
id: passed
run: |
if $( gh pr view ${{ env.EVENT }} --repo ${{ env.OWNER }}/${{ env.REPO }} --json "labels" --jq ".[].[].name" | grep --quiet ${{ env.LABEL_SUCCESS }}); then
echo "PASSED=true" >> $GITHUB_OUTPUT;
else
echo "PASSED=false" >> $GITHUB_OUTPUT;
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event.number }} # This is either the issue or pr
pkgdown_build_passed:
if: ${{ always() }}
needs:
- pkgdown_build
- record_passed_label
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
steps:
- name: Assert that either job passed or the label is present
run: |
# First, check if the workflow was triggered by the correct label.
# If not, the relevant jobs were likely skipped, and we should not fail the workflow.
if [[ "${{ github.event.label.name }}" != "${{ env.LABEL_CHECK }}" ]]; then
echo "Workflow not triggered by '${{ env.LABEL_CHECK }}' label (actual label: '${{ github.event.label.name }}')."
echo "Skipping status assertion and exiting gracefully."
exit 0
fi
# If triggered by the correct label, proceed with the status check.
pkgdown_build_RESULT="${{ needs.pkgdown_build.result }}"
PASSED_LABEL_EXISTS="${{ needs.record_passed_label.outputs.passed }}"
echo "Verifying R CMD check status..."
echo " - pkgdown_build job result: ${pkgdown_build_RESULT}"
echo " - '${{ env.LABEL_SUCCESS }}' label found on PR: ${PASSED_LABEL_EXISTS}"
if [[ "${pkgdown_build_RESULT}" == 'success' ]]; then
echo "=> Success: pkgdown_build job passed."
exit 0
elif [[ "${PASSED_LABEL_EXISTS}" == 'true' ]]; then
echo "=> Success: Although pkgdown_build job result was '${pkgdown_build_RESULT}', the '${{ env.LABEL_SUCCESS }}' label already exists on the PR."
exit 0
else
echo "=> Failure: pkgdown_build job result was '${pkgdown_build_RESULT}' and the '${{ env.LABEL_SUCCESS }}' label was not found."
exit 1
fi