From 2e879b183648b62baf839d8e89183324f48cdaeb Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:55:36 +0800 Subject: [PATCH] [Tool] Add version label to issue when main pr was merged (backport #44602) (#44615) Co-authored-by: andyziye <108652123+andyziye@users.noreply.github.com> --- .github/workflows/ci-merged.yml | 54 +++++++++++++++++++++--- .github/workflows/ci-pipeline-branch.yml | 1 + .github/workflows/ci-pipeline.yml | 1 + 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-merged.yml b/.github/workflows/ci-merged.yml index d556cf40b24f24..d4cfcb6269bc88 100644 --- a/.github/workflows/ci-merged.yml +++ b/.github/workflows/ci-merged.yml @@ -224,16 +224,58 @@ jobs: VERSION_LABEL: ${{ steps.prepare_version_label.outputs.LABEL }} run: | gh pr edit ${PR_NUMBER} -R ${GITHUB_REPOSITORY} --add-label "${VERSION_LABEL}" - + + update_version_label_for_main_feature: + runs-on: [ self-hosted, quick ] + if: > + github.base_ref == 'main' && github.event.pull_request.merged == true && + !contains(github.event.pull_request.labels.*.name, 'sync') && + startsWith(github.event.pull_request.title, '[Feature]') + env: + PR_NUMBER: ${{ github.event.number }} + outputs: + VERSION_LABEL: ${{ steps.prepare_version_label.outputs.LABEL }} + steps: + - name: prepare version label + id: prepare_version_label + if: always() + env: + GH_TOKEN: ${{ secrets.PAT }} + run: | + rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull >/dev/null + version=$(./scripts/get_next_release_tag.sh) + version_label="version:${version}" + echo "LABEL=${version_label}" >> $GITHUB_OUTPUT + gh label create "${version_label}" -R ${GITHUB_REPOSITORY} -c 1d76db -f + + - name: add version label + if: always() + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION_LABEL: ${{ steps.prepare_version_label.outputs.LABEL }} + run: | + gh pr edit ${PR_NUMBER} -R ${GITHUB_REPOSITORY} --add-label "${VERSION_LABEL}" + update_feature_issue: runs-on: [ self-hosted, quick ] - needs: update_backport_merged_msg + needs: + - update_backport_merged_msg + - update_version_label_for_main_feature if: > - !contains(github.event.pull_request.labels.*.name, 'sync') && startsWith(github.event.pull_request.title, '[Feature]') + always() && !contains(github.event.pull_request.labels.*.name, 'sync') && startsWith(github.event.pull_request.title, '[Feature]') env: - VERSION_LABEL: ${{ needs.update_backport_merged_msg.outputs.VERSION_LABEL }} + BRANCH_VERSION_LABEL: ${{ needs.update_backport_merged_msg.outputs.VERSION_LABEL }} + MAIN_VERSION_LABEL: ${{ needs.update_version_label_for_main_feature.outputs.VERSION_LABEL }} + steps: - - name: Update Issue Body & Label + - name: Update Issue Body & Label(main) + if: github.base_ref == 'main' && env.MAIN_VERSION_LABEL != '' + run: | + rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull >/dev/null + python3 scripts/get_pr_issue.py update_issue ${GITHUB_REPOSITORY} ${PR_NUMBER} ${MAIN_VERSION_LABEL} + + - name: Update Issue Body & Label(branch) + if: always() && github.base_ref != 'main' && env.BRANCH_VERSION_LABEL != '' run: | rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull >/dev/null - python3 scripts/get_pr_issue.py update_issue ${GITHUB_REPOSITORY} ${PR_NUMBER} ${VERSION_LABEL} + python3 scripts/get_pr_issue.py update_issue ${GITHUB_REPOSITORY} ${PR_NUMBER} ${BRANCH_VERSION_LABEL} \ No newline at end of file diff --git a/.github/workflows/ci-pipeline-branch.yml b/.github/workflows/ci-pipeline-branch.yml index 9923f0e594d308..1aee4ec95c1849 100644 --- a/.github/workflows/ci-pipeline-branch.yml +++ b/.github/workflows/ci-pipeline-branch.yml @@ -161,6 +161,7 @@ jobs: path: image_cache.info retention-days: 1 overwrite: true + if-no-files-found: ignore - name: Clean ENV if: always() diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index a2c2809030134c..a1614a6a0dcaff 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -173,6 +173,7 @@ jobs: path: image_cache.info retention-days: 1 overwrite: true + if-no-files-found: ignore - name: Clean ENV if: always() && needs.be-checker.outputs.thirdparty_filter == 'true'