Skip to content

Instantly share code, notes, and snippets.

@oraNod
Created April 29, 2024 15:48
Show Gist options
  • Save oraNod/770209b57966da961f0459cefcf2891f to your computer and use it in GitHub Desktop.
Save oraNod/770209b57966da961f0459cefcf2891f to your computer and use it in GitHub Desktop.
variation of the package docs publishing workflow that creates a new release in the dest repo
---
name: Ansible package docs build
on:
workflow_dispatch:
inputs:
repository-owner:
description: GitHub account or org that owns the repository
required: true
default: ansible
repository-name:
description: Name of the GitHub repository
required: true
default: ansible-documentation
repository-branch:
description: Branch, tag, or commit SHA
required: true
default: devel
language:
type: choice
description: Language
required: true
default: english
options:
- english
- japanese
ansible-package-version:
type: choice
description: Version of the Ansible community package to build
required: true
default: devel
options:
- devel
- '10'
- '9'
- '8'
- '7'
latest-symlink:
type: boolean
description: Add latest symlink
required: true
production:
type: boolean
description: Deploy build to production
required: true
env:
PACKAGE_VERSION: ${{ github.event.inputs.ansible-package-version }}
LANGUAGE: ${{ github.event.inputs.language }}
jobs:
build-package-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout Ansible documentation
uses: actions/checkout@v4
with:
repository: >-
${{
github.event.inputs.repository-owner
}}/${{
github.event.inputs.repository-name
}}
ref: ${{ github.event.inputs.repository-branch }}
path: build-directory
- name: Setup nox
uses: wntrblm/nox@2024.04.15
- name: Output Python info
run: python --version --version && which python
- name: Graft ansible-core
run: nox -s clone-core
working-directory: build-directory
- name: Install project requirements
run: >-
python -m pip install
-r tests/requirements.in
-c tests/requirements.txt
working-directory: build-directory
- name: Set the COLLECTION_LIST variable
if: env.PACKAGE_VERSION != 'devel'
run: >-
echo COLLECTION_LIST='"${PACKAGE_VERSION}"'
>> "${GITHUB_ENV}"
- name: Set the VERSION variable
run: |
if [ ${LANGUAGE} == "english" ]; then
echo VERSION="${PACKAGE_VERSION}" >> "${GITHUB_ENV}"
elif [ ${LANGUAGE} == "japanese" ]; then
echo VERSION="${PACKAGE_VERSION}_ja" >> "${GITHUB_ENV}"
fi
- name: Build the Ansible community package docs
run: make coredocs
working-directory: build-directory/docs/docsite
- name: Create latest symlink
if: fromJSON(github.event.inputs.latest-symlink)
run: ln -s "${VERSION}" _build/html/latest
working-directory: build-directory/docs/docsite
- name: Create a tarball with the build contents
#if: >-
#!fromJSON(github.event.inputs.production)
run: >-
tar -czvf
ansible-package-docs-html-"${PACKAGE_VERSION}"-$(date '+%Y-%m-%d')-${{
github.run_id
}}-${{
github.run_number
}}-${{
github.run_attempt
}}.tar.gz
--directory=_build/html/ .
working-directory: build-directory/docs/docsite
- name: Create a downloadable archive that contains the tarball
if: >-
!fromJSON(github.event.inputs.production)
uses: actions/upload-artifact@v4
with:
name: package-docs-build
path: build-directory/docs/docsite/ansible-package-docs-html-*.tar.gz
retention-days: 7
#- name: Checkout the deploy directory
#if: fromJSON(github.event.inputs.production)
#uses: actions/checkout@v4
#with:
#repository: oraNod/ansible-docs-deploy
#ref: main
#path: deploy-directory
#token: ${{ secrets.TEST_RELEASE_TOKEN }}
#- name: Copy the generated HTML and assets
#if: fromJSON(github.event.inputs.production)
#run: >-
#rsync -av --delete --mkpath
#build-directory/docs/docsite/_build/html/
#deploy-directory/docs-build
- name: Try uploading as a release
if: fromJSON(github.event.inputs.production)
uses: softprops/action-gh-release@v2
with:
files: build-directory/docs/docsite/ansible-package-docs-html-*.tar.gz
repository: oraNod/ansible-docs-deploy
token: ${{ secrets.TEST_RELEASE_TOKEN }}
tag_name: test01
#- name: Add generated HTML and assets
#if: fromJSON(github.event.inputs.production)
#run: |
#git config --local user.email "dnaro@redhat.com"
#git config --local user.name "dnaro"
#git add . --all --force
#working-directory: deploy-directory
#- name: Commit generated HTML and assets
#if: fromJSON(github.event.inputs.production)
#run: >-
#git commit -m "Push docs build $(date '+%Y-%m-%d')-${{
#github.run_id
#}}-${{
#github.run_number
#}}-${{
#github.run_attempt
#}}"
#working-directory: deploy-directory
#- name: Push build to deploy repository
#if: fromJSON(github.event.inputs.production)
#uses: ad-m/github-push-action@master
#with:
#github_token: ${{ secrets.TEST_RELEASE_TOKEN }}
#branch: main
#repository: oraNod/ansible-docs-deploy
#directory: deploy-directory
#force: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment