From d9e615d4fb76f07417c4af35e22268e3648770b1 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Thu, 8 Aug 2024 20:33:25 +0200 Subject: [PATCH] Automatically add backport labels for release branch --- .ci/scripts/create_release_branch.sh | 5 +++++ .github/workflows/pr_checks.yml | 2 +- .github/workflows/release_branch.yml | 13 +++++++++++++ .../.ci/scripts/create_release_branch.sh | 5 +++++ .../.github/workflows/pr_checks.yml | 2 +- .../.github/workflows/release_branch.yml | 13 +++++++++++++ .../lint_requirements.txt | 2 +- 7 files changed, 39 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/create_release_branch.sh b/.ci/scripts/create_release_branch.sh index d12237ce1..09e5a131a 100755 --- a/.ci/scripts/create_release_branch.sh +++ b/.ci/scripts/create_release_branch.sh @@ -30,3 +30,8 @@ git add docs/versions.txt bump-my-version bump minor --commit --message $'Bump version to {new_version}' --allow-dirty git push origin "${NEW_BRANCH}" + +if [ "${GITHUB_ENV:-}" ] +then + echo "NEW_BRANCH=${NEW_BRANCH}" >> "${GITHUB_ENV}" +fi diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index a06a4d5d7..ef9c6ff8f 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -13,7 +13,7 @@ concurrency: cancel-in-progress: true jobs: - single_commit: + apply_labels: runs-on: "ubuntu-latest" name: "Label PR" permissions: diff --git a/.github/workflows/release_branch.yml b/.github/workflows/release_branch.yml index 77723e1dd..04f8dace1 100644 --- a/.github/workflows/release_branch.yml +++ b/.github/workflows/release_branch.yml @@ -30,4 +30,17 @@ jobs: body: "" branch: "bump_version" delete-branch: true + - name: "Add Backport Label for new Branch" + uses: "actions/github-script@v7" + with: + script: | + const { NEW_BRANCH } = process.env; + const labelName = "backport-" + NEW_BRANCH; + + await github.rest.issues.createLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: labelName, + color: "C8780A", + }); ... diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/create_release_branch.sh b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/create_release_branch.sh index 0f33354ad..e3e15f948 100755 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/create_release_branch.sh +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/create_release_branch.sh @@ -32,3 +32,8 @@ git add docs/versions.txt bump-my-version bump minor --commit --message $'Bump version to {new_version}' --allow-dirty git push origin "${NEW_BRANCH}" + +if [ "${GITHUB_ENV:-}" ] +then + echo "NEW_BRANCH=${NEW_BRANCH}" >> "${GITHUB_ENV}" +fi diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/pr_checks.yml b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/pr_checks.yml index a06a4d5d7..ef9c6ff8f 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/pr_checks.yml +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/pr_checks.yml @@ -13,7 +13,7 @@ concurrency: cancel-in-progress: true jobs: - single_commit: + apply_labels: runs-on: "ubuntu-latest" name: "Label PR" permissions: diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/release_branch.yml b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/release_branch.yml index 77723e1dd..04f8dace1 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/release_branch.yml +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.github/workflows/release_branch.yml @@ -30,4 +30,17 @@ jobs: body: "" branch: "bump_version" delete-branch: true + - name: "Add Backport Label for new Branch" + uses: "actions/github-script@v7" + with: + script: | + const { NEW_BRANCH } = process.env; + const labelName = "backport-" + NEW_BRANCH; + + await github.rest.issues.createLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: labelName, + color: "C8780A", + }); ... diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/lint_requirements.txt b/cookiecutter/ci/{{ cookiecutter.__project_name }}/lint_requirements.txt index 81f9af132..afc02fc13 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/lint_requirements.txt +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/lint_requirements.txt @@ -1,6 +1,6 @@ # Lint requirements black==24.8.0 -flake8==7.1.0 +flake8==7.1.1 flake8-pyproject==1.2.3 isort==5.13.2 mypy==1.11.1