66 git_tag :
77 type : string
88 description : The git tag (version) from the calling workflow
9- required : true
9+
1010 workflow_dispatch :
1111 inputs :
1212 git_tag :
1313 type : string
1414 description : The git tag (version) to use for `$TAG`
15- required : true
1615
1716jobs :
1817 docs-ci :
1918 runs-on : ubuntu-latest
2019 env :
2120 GH_TOKEN : ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
21+ # keeping TAG for cases docs repo workflow is triggered with tag input
2222 TAG : ${{ inputs.git_tag }}
23+ REF_NAME : ${{ github.ref_name }}
24+ # in case of pushed PR, ref_head specifies PR's branch
25+ REF_HEAD : ${{ github.head_ref }}
26+ # will be used to specify repo tar url according to PR id
27+ PR_NUMBER : ${{ github.event.number }}
2328 PR_TITLE_PREFIX : " task: update documentation for"
2429 steps :
2530 - uses : actions/checkout@v4
3136 with :
3237 go-version : 1.23.x
3338 - name : Make docs
39+ # handle triggered workflow by pushed tag or PR
3440 run : |
41+ if [[ -n $PR_NUMBER ]]; then
42+ export BRANCH=$REF_HEAD
43+ echo "REF_NAME=$REF_HEAD" >> $GITHUB_ENV
44+ echo "COMMIT_SUFFIX=pull/$PR_NUMBER" >> $GITHUB_ENV
45+ else
46+ TAG="${TAG:-$REF_NAME}"
47+ export TAG
48+ echo "TAG=$TAG" >> $GITHUB_ENV
49+ echo "COMMIT_SUFFIX=$TAG" >> $GITHUB_ENV
50+ fi
51+
3552 make api-docs helm-docs generate-docs-versions-var
3653 - name : Close any existing documentation PRs
3754 run : |
@@ -40,23 +57,22 @@ jobs:
4057 done
4158 - name : Create PR
4259 env :
60+ REF_NAME : ${{ github.ref_name }}
4361 DOWNSTREAM_REPO_OWNER : nvidia-ci-cd
44- DOWNSTREAM_FEATURE_BRANCH : update-docs-for-${{ env.TAG }}
62+ DOWNSTREAM_FEATURE_BRANCH : update-docs-for-${{ env.REF_NAME }}
4563 UPSTREAM_REPO_OWNER : Mellanox
4664 UPSTREAM_DEFAULT_BRANCH : main
47- COMMIT_MESSAGE : ${{ env.PR_TITLE_PREFIX }} ${{ env.TAG }}
4865 run : |
49- git config user.name nvidia-ci-cd
66+ git config user.name nvidia-ci-cd
5067 git config user.email [email protected] 5168 gh repo fork --remote --default-branch-only
5269 gh repo sync $DOWNSTREAM_REPO_OWNER/network-operator-docs --source $UPSTREAM_REPO_OWNER/network-operator-docs --branch $UPSTREAM_DEFAULT_BRANCH
53-
5470 git checkout -b $DOWNSTREAM_FEATURE_BRANCH
55- git status
5671 git add docs
72+ COMMIT_MESSAGE="$PR_TITLE_PREFIX $COMMIT_SUFFIX"
5773 git commit -m "$COMMIT_MESSAGE"
5874
59- git push -u origin $DOWNSTREAM_FEATURE_BRANCH
75+ git push -u origin $DOWNSTREAM_FEATURE_BRANCH --force
6076 gh pr create \
6177 --head $DOWNSTREAM_REPO_OWNER:$DOWNSTREAM_FEATURE_BRANCH \
6278 --base $UPSTREAM_DEFAULT_BRANCH \
0 commit comments