Documentation CI #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Documentation CI | ||
on: | ||
workflow_call: | ||
inputs: | ||
git_tag: | ||
type: string | ||
description: The git tag (version) from the calling workflow | ||
required: false | ||
secrets: | ||
token: | ||
type: string | ||
description: The github token | ||
required: true | ||
workflow_dispatch: | ||
inputs: | ||
git_tag: | ||
type: string | ||
description: The git tag (version) to use for `$TAG` | ||
required: false | ||
secrets: | ||
token: | ||
type: string | ||
description: The github token | ||
required: true | ||
jobs: | ||
docs-ci: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} | ||
TAG: ${{ inputs.git_tag }} | ||
PR_TITLE_PREFIX: "task: update documentation for" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.repository_owner }}/network-operator-docs # repo must be explicitly set here for workflow calling to behave correctly | ||
token: ${{ inputs.token || secrets.GH_TOKEN_NVIDIA_CI_CD }} # token must be explicitly set here for push to work in following step | ||
- name: Setup Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: 1.23.x | ||
- name: Make docs | ||
run: | | ||
make api-docs helm-docs generate-docs-versions-var | ||
- name: Close any existing documentation PRs | ||
run: | | ||
for pr_number in $(gh pr list --search "$PR_TITLE_PREFIX" --json number --jq ".[].number"); do | ||
gh pr close $pr_number | ||
done | ||
- name: Create PR | ||
env: | ||
DOWNSTREAM_REPO_OWNER: heyvister1 | ||
DOWNSTREAM_FEATURE_BRANCH: update-docs-for-${{ env.TAG }} | ||
UPSTREAM_REPO_OWNER: heyvister1 | ||
UPSTREAM_DEFAULT_BRANCH: main | ||
COMMIT_MESSAGE: ${{ env.PR_TITLE_PREFIX }} ${{ env.TAG }} | ||
run: | | ||
git config user.name heyvister1 | ||
git config user.email [email protected] | ||
git checkout test-netops-docs-workflow | ||
git checkout -b $DOWNSTREAM_FEATURE_BRANCH | ||
git status | ||
git add docs | ||
git commit -m "$COMMIT_MESSAGE" | ||
git push -u origin $DOWNSTREAM_FEATURE_BRANCH | ||
gh pr create \ | ||
--head $DOWNSTREAM_REPO_OWNER:$DOWNSTREAM_FEATURE_BRANCH \ | ||
--base $UPSTREAM_DEFAULT_BRANCH \ | ||
--title "$COMMIT_MESSAGE" \ | ||
--body "Created by the *${{ github.job }}* job in [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." |