diff --git a/.github/workflows/docs-ci.yaml b/.github/workflows/docs-ci.yaml index 74d1d9b..6966241 100644 --- a/.github/workflows/docs-ci.yaml +++ b/.github/workflows/docs-ci.yaml @@ -6,13 +6,14 @@ on: git_tag: type: string description: The git tag (version) from the calling workflow - required: true + required: false + workflow_dispatch: inputs: git_tag: type: string description: The git tag (version) to use for `$TAG` - required: true + required: false jobs: docs-ci: @@ -20,7 +21,12 @@ jobs: env: GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} TAG: ${{ inputs.git_tag }} + REF_NAME: ${{ github.ref_name }} + REF_TYPE: ${{ github.ref_type }} + REF_HEAD: ${{ github.head_ref }} + PR_NUMBER: ${{ github.event.number }} PR_TITLE_PREFIX: "task: update documentation for" + COMMIT_SUFFIX: ${{ inputs.git_tag }} steps: - uses: actions/checkout@v4 with: @@ -32,6 +38,18 @@ jobs: go-version: 1.23.x - name: Make docs 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}" + BRANCH="${REF_NAME:-master}" + export TAG BRANCH + echo "TAG=$TAG" >> $GITHUB_ENV + echo "BRANCH=$BRANCH" >> $GITHUB_ENV + fi + make api-docs helm-docs generate-docs-versions-var - name: Close any existing documentation PRs run: | @@ -40,23 +58,23 @@ jobs: done - name: Create PR env: - DOWNSTREAM_REPO_OWNER: nvidia-ci-cd - DOWNSTREAM_FEATURE_BRANCH: update-docs-for-${{ env.TAG }} - UPSTREAM_REPO_OWNER: Mellanox + REF_NAME: ${{ github.ref_name }} + DOWNSTREAM_REPO_OWNER: heyvister1 + DOWNSTREAM_FEATURE_BRANCH: update-docs-for-${{ env.REF_NAME }} + UPSTREAM_REPO_OWNER: heyvister1 UPSTREAM_DEFAULT_BRANCH: main - COMMIT_MESSAGE: ${{ env.PR_TITLE_PREFIX }} ${{ env.TAG }} run: | - git config user.name nvidia-ci-cd - git config user.email svc-cloud-orch-gh@nvidia.com - gh repo fork --remote --default-branch-only + git config user.name heyvister1 + git config user.email iheyvi@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 \ diff --git a/Makefile b/Makefile index 3089151..59bd647 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,28 @@ GOBIN=$(shell go env GOBIN) endif export PATH:=$(GOBIN):${PATH} +# TODO: Add another condition for PR Tag/PR/Branch 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//') +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/$(if $(TAG),tags/$(TAG),heads/$(BRANCH)).tar.gz +REPO_TAR_URL = https://github.com/heyvister1/network-operator/archive/refs/$(REFS_NAME)/head.tar.gz +#REPO_TAR_URL = github.com/heyvister1/network-operator/archive/refs/pull/2/head.tar.gz # release.yaml location -RELEASE_YAML_URL ?= https://raw.githubusercontent.com/Mellanox/network-operator/$(if $(TAG),$(TAG),$(BRANCH))/hack/release.yaml +#RELEASE_YAML_URL ?= https://raw.githubusercontent.com/Mellanox/network-operator/$(if $(TAG),$(TAG),$(BRANCH))/hack/release.yaml +RELEASE_YAML_URL = https://raw.githubusercontent.com/heyvister1/network-operator/$(if $(TAG),$(TAG),$(BRANCH))/hack/release.yaml # Path to download the crd api to. CRD_API_DEP_ROOT = $(BUILDDIR)/crd