Skip to content

Commit

Permalink
[Tool] Add version label to issue when main pr was merged (backport #…
Browse files Browse the repository at this point in the history
…44602) (#44615)

Co-authored-by: andyziye <[email protected]>
  • Loading branch information
mergify[bot] and andyziye authored Apr 23, 2024
1 parent 4c9a6b7 commit 2e879b1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
54 changes: 48 additions & 6 deletions .github/workflows/ci-merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
1 change: 1 addition & 0 deletions .github/workflows/ci-pipeline-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ jobs:
path: image_cache.info
retention-days: 1
overwrite: true
if-no-files-found: ignore

- name: Clean ENV
if: always()
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 2e879b1

Please sign in to comment.