Skip to content

Add GHA dispatch with TAG input #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 52 additions & 12 deletions .github/workflows/Doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ name: doxygen
on:
push:
branches: main
workflow_dispatch:
inputs:
tag:
description: 'The ITK tag or hash with which to build the Doxygen documentation.'
required: false
default: 'master'
type: string
publish:
description: 'Create a GitHub release with the Doxygen documentation.'
required: true
default: 'false'
type: boolean

schedule:
- cron: '0 0 * * *'

Expand All @@ -19,9 +32,36 @@ jobs:
run: |
docker build -f Dockerfile -t itk-doxygen .

- name: Configure Variables
id: vars
run: |
# if running workflow_dispatch, set the target branch to the tag input if set, otherwise set it to master
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ "${{ github.event.inputs.tag }}" != "" ]]; then
echo "branch=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "branch=master" >> $GITHUB_ENV
fi
else
echo "branch=master" >> $GITHUB_ENV
fi

# Set publish to the input value if running workflow_dispatch, otherwise set it to true of running on main branch
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "publish=${{ github.event.inputs.publish }}" >> $GITHUB_ENV
echo "publish_tag=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "publish=true" >> $GITHUB_ENV
echo "publish_tag=latest" >> $GITHUB_ENV
else
echo "publish=false" >> $GITHUB_ENV
fi

- name: Docker Doxygen generation
env:
TAG: env.branch
run: |
docker run --name itk-dox itk-doxygen
docker run --env TAG --name itk-dox itk-doxygen
mkdir -p artifacts
docker cp itk-dox:/ITKDoxygen.tar.gz artifacts/ITKDoxygen-${GITHUB_SHA}.tar.gz
docker cp itk-dox:/ITKDoxygenXML.tar.gz artifacts/ITKDoxygenXML-${GITHUB_SHA}.tar.gz
Expand All @@ -35,26 +75,26 @@ jobs:
artifacts/ITKDoxygen-*.tar.gz

- name: Publish to latest GitHub Release
if: github.ref == 'refs/heads/main'
if: env.publish == 'true'
run: |
sudo apt install -y zstd

pushd artifacts

cp ITKDoxygen-*.tar.gz InsightDoxygenDocHtml-latest.tar.gz
gunzip InsightDoxygenDocHtml-latest.tar.gz
zstd -f -10 -T6 --long=31 InsightDoxygenDocHtml-latest.tar -o InsightDoxygenDocHtml-latest.tar.zst
gzip -9 InsightDoxygenDocHtml-latest.tar
cp ITKDoxygen-*.tar.gz InsightDoxygenDocHtml-${publish_tag}.tar.gz
gunzip InsightDoxygenDocHtml-${publish_tag}.tar.gz
zstd -f -10 -T6 --long=31 InsightDoxygenDocHtml-${publish_tag}.tar -o InsightDoxygenDocHtml-${publish_tag}.tar.zst
gzip -9 InsightDoxygenDocHtml-${publish_tag}.tar

cp ITKDoxygenXML-*.tar.gz InsightDoxygenDocXml-latest.tar.gz
gunzip InsightDoxygenDocXml-latest.tar.gz
zstd -f -10 -T6 --long=31 InsightDoxygenDocXml-latest.tar -o InsightDoxygenDocXml-latest.tar.zst
gzip -9 InsightDoxygenDocXml-latest.tar
cp ITKDoxygenXML-*.tar.gz InsightDoxygenDocXml-${publish_tag}.tar.gz
gunzip InsightDoxygenDocXml-${publish_tag}.tar.gz
zstd -f -10 -T6 --long=31 InsightDoxygenDocXml-${publish_tag}.tar -o InsightDoxygenDocXml-${publish_tag}.tar.zst
gzip -9 InsightDoxygenDocXml-${publish_tag}.tar

popd

gh release delete -R InsightSoftwareConsortium/ITKDoxygen --cleanup-tag latest --yes
gh release create latest --notes="ITK Doxygen documentation built from the ITK master branch." --prerelease --title "ITKDoxygen Latest" -R InsightSoftwareConsortium/ITKDoxygen ./artifacts/InsightDoxygen*
gh release delete -R InsightSoftwareConsortium/ITKDoxygen --cleanup-tag ${publish_tag} --yes
gh release create ${publish_tag} --notes="ITK Doxygen documentation built from the ITK main branch." --prerelease --title "ITKDoxygen ${publish_tag}" -R InsightSoftwareConsortium/ITKDoxygen ./artifacts/InsightDoxygen*
env:
GH_TOKEN: ${{ secrets.github_token }}

Expand Down
Loading