Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 24 additions & 8 deletions .github/workflows/docs-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ on:
git_tag:
type: string
description: The git tag (version) from the calling workflow
required: true

workflow_dispatch:
inputs:
git_tag:
type: string
description: The git tag (version) to use for `$TAG`
required: true

jobs:
docs-ci:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
# keeping TAG for cases docs repo workflow is triggered with tag input
TAG: ${{ inputs.git_tag }}
REF_NAME: ${{ github.ref_name }}
# in case of pushed PR, ref_head specifies PR's branch
REF_HEAD: ${{ github.head_ref }}
# will be used to specify repo tar url according to PR id
PR_NUMBER: ${{ github.event.number }}
PR_TITLE_PREFIX: "task: update documentation for"
steps:
- uses: actions/checkout@v4
Expand All @@ -31,7 +36,19 @@ jobs:
with:
go-version: 1.23.x
- name: Make docs
# handle triggered workflow by pushed tag or PR
run: |
if [[ -n $PR_NUMBER ]]; then
export BRANCH=$REF_HEAD
echo "REF_NAME=$REF_HEAD" >> $GITHUB_ENV
echo "COMMIT_SUFFIX=pull/$PR_NUMBER" >> $GITHUB_ENV
else
TAG="${TAG:-$REF_NAME}"
export TAG
echo "TAG=$TAG" >> $GITHUB_ENV
echo "COMMIT_SUFFIX=$TAG" >> $GITHUB_ENV
fi

make api-docs helm-docs generate-docs-versions-var
- name: Close any existing documentation PRs
run: |
Expand All @@ -40,23 +57,22 @@ jobs:
done
- name: Create PR
env:
REF_NAME: ${{ github.ref_name }}
DOWNSTREAM_REPO_OWNER: nvidia-ci-cd
DOWNSTREAM_FEATURE_BRANCH: update-docs-for-${{ env.TAG }}
DOWNSTREAM_FEATURE_BRANCH: update-docs-for-${{ env.REF_NAME }}
UPSTREAM_REPO_OWNER: Mellanox
UPSTREAM_DEFAULT_BRANCH: main
COMMIT_MESSAGE: ${{ env.PR_TITLE_PREFIX }} ${{ env.TAG }}
run: |
git config user.name nvidia-ci-cd
git config user.name nvidia-ci-cd
git config user.email svc-cloud-orch-gh@nvidia.com
gh repo fork --remote --default-branch-only
gh repo sync $DOWNSTREAM_REPO_OWNER/network-operator-docs --source $UPSTREAM_REPO_OWNER/network-operator-docs --branch $UPSTREAM_DEFAULT_BRANCH

git checkout -b $DOWNSTREAM_FEATURE_BRANCH
git status
git add docs
COMMIT_MESSAGE="$PR_TITLE_PREFIX $COMMIT_SUFFIX"
git commit -m "$COMMIT_MESSAGE"

git push -u origin $DOWNSTREAM_FEATURE_BRANCH
git push -u origin $DOWNSTREAM_FEATURE_BRANCH --force
gh pr create \
--head $DOWNSTREAM_REPO_OWNER:$DOWNSTREAM_FEATURE_BRANCH \
--base $UPSTREAM_DEFAULT_BRANCH \
Expand Down
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ export PATH:=$(GOBIN):${PATH}

BRANCH ?= master
TAG ?=
# Then using TAG, the tar file starts with v, but the extracted dir does not
SRC := $(shell echo $(if $(TAG),$(TAG),$(BRANCH)) | sed 's/^v//')
# Handling the following use cases for repo url:
# 1. PR - refs/pull/<PR id>
# 2. TAG - refs/<tag name (omitted 'v' prefix in url)>
# 3. BRANCH - refs/<branch name>
ifdef PR_NUMBER
SRC = refs-pull-$(PR_NUMBER)-head
REFS_NAME = pull/$(PR_NUMBER)
else ifdef TAG
SRC = $(shell echo $(TAG) | sed 's/^v//')
REFS_NAME=tags/$(TAG)
else
SRC = $(BRANCH)
REFS_NAME=$(BRANCH)
endif

# Network Operator source tar location
REPO_TAR_URL ?= https://github.com/Mellanox/network-operator/archive/refs/$(if $(TAG),tags/$(TAG),heads/$(BRANCH)).tar.gz
REPO_TAR_URL ?= https://github.com/Mellanox/network-operator/archive/refs/$(REFS_NAME)/head.tar.gz
# release.yaml location
RELEASE_YAML_URL ?= https://raw.githubusercontent.com/Mellanox/network-operator/$(if $(TAG),$(TAG),$(BRANCH))/hack/release.yaml

Expand Down