From a06df401272d2d26f0bcad3036ce6dc82d8581b2 Mon Sep 17 00:00:00 2001 From: Ido Heyvi Date: Tue, 12 Nov 2024 12:15:08 +0200 Subject: [PATCH] update Makefile #2 --- .github/workflows/docs-ci.yaml | 25 ++++++++++++++++++++----- Makefile | 12 +++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs-ci.yaml b/.github/workflows/docs-ci.yaml index 9915f33..b4c4455 100644 --- a/.github/workflows/docs-ci.yaml +++ b/.github/workflows/docs-ci.yaml @@ -37,8 +37,11 @@ jobs: GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} TAG: ${{ inputs.git_tag }} REF_NAME: ${{ github.ref_name }} - REF_TYPE: ${{ github.ref_type }} + 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: @@ -52,7 +55,18 @@ jobs: run: | echo "REF_TYPE:" $REF_TYPE echo "REF_NAME:" $REF_NAME - BRANCH=$REF_NAME + echo "REF_HEAD:" $REF_HEAD + if [[ -n $PR_NUMBER ]]; then + echo PR_NUMBER=$PR_NUMBER + export PR_BRANCH=$REF_HEAD + echo "COMMIT_SUFFIX=PR $PR_NUMBER" >> $GITHUB_ENV + fi + + COMMIT_SUFFIX="PR 3" >> $GITHUB_ENV + + echo "PR_BRANCH:" $PR_BRANCH + git pull + git checkout test-netops-docs-workflow #$REF_HEAD make api-docs helm-docs generate-docs-versions-var - name: Close any existing documentation PRs run: | @@ -66,18 +80,19 @@ jobs: DOWNSTREAM_FEATURE_BRANCH: update-docs-for-${{ env.REF_NAME }} UPSTREAM_REPO_OWNER: heyvister1 UPSTREAM_DEFAULT_BRANCH: main - COMMIT_MESSAGE: ${{ env.PR_TITLE_PREFIX }} ${{ env.REF_NAME }} + #COMMIT_MESSAGE: ${{ env.PR_TITLE_PREFIX }} ${{ env.COMMIT_SUFFIX }} run: | 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 pull - git checkout test-netops-docs-workflow + git checkout test-netops-docs-workflow #$REF_HEAD 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 diff --git a/Makefile b/Makefile index ce64227..90f3055 100644 --- a/Makefile +++ b/Makefile @@ -12,15 +12,21 @@ endif export PATH:=$(GOBIN):${PATH} # TODO: Add another condition for PR Tag/PR/Branch +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 + BRANCH = $(PR_BRANCH) +else + SRC = $(shell echo $(if $(TAG),$(TAG),$(BRANCH)) | sed 's/^v//') +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/heyvister1/network-operator/archive/refs/$(if $(TAG),tags/$(TAG),heads/$(BRANCH)).tar.gz - +REPO_TAR_URL = https://github.com/heyvister1/network-operator/archive/refs/$(if $(TAG),tags/$(TAG),pull/$(PR_NUMBER))/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/heyvister1/network-operator/$(if $(TAG),$(TAG),$(BRANCH))/hack/release.yaml