Skip to content

Commit

Permalink
[Tool] Add version label in merge pipeline (backport #37640) (#37641)
Browse files Browse the repository at this point in the history
Co-authored-by: andyziye <[email protected]>
  • Loading branch information
mergify[bot] and andyziye authored Dec 22, 2023
1 parent bca983c commit c2ca471
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/ci-merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request_target:
branches:
- main
- 'branch*'
- 'branch-[0-9].[0-9]'
types:
- closed
permissions:
Expand Down Expand Up @@ -168,25 +168,49 @@ jobs:
gh run list --workflow ${yaml} -R ${REPO} -b ${GITHUB_HEAD_REF} --json databaseId -q '.[].databaseId' | xargs gh run cancel -R ${REPO} || true
update_backport_merged_msg:
runs-on: ubuntu-latest
runs-on: [ self-hosted, quick ]
if: >
github.base_ref != 'main' && github.event.pull_request.merged == true &&
contains(github.event.pull_request.title, '(backport #') &&
!contains(github.event.pull_request.labels.*.name, 'sync')
github.base_ref != 'main' && github.event.pull_request.merged == true
env:
LABEL: ${{ github.base_ref }}-merged
PR_NUMBER: ${{ github.event.number }}
steps:
- name: prepare label
- name: prepare merge label
if: >
!contains(github.event.pull_request.labels.*.name, 'sync') &&
contains(github.event.pull_request.title, '(backport #')
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
gh label create ${LABEL} -R ${GITHUB_REPOSITORY} -c 98C1D7 -f
gh label create "${LABEL}" -R ${GITHUB_REPOSITORY} -c 98C1D7 -f
- name: commit_sha
if: always()
- name: add merge label
if: >
always() && !contains(github.event.pull_request.labels.*.name, 'sync') &&
contains(github.event.pull_request.title, '(backport #')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ORI_PR=$(echo "${{ github.event.pull_request.title }}" | grep -oP '\(backport #\K\d+' | tail -n 1)
gh pr edit ${ORI_PR} -R ${GITHUB_REPOSITORY} --add-label "${BRANCH}-merged"
gh pr edit ${ORI_PR} -R ${GITHUB_REPOSITORY} --add-label "${LABEL}"
- 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}"

0 comments on commit c2ca471

Please sign in to comment.