diff --git a/.github/workflows/issue_comment_edited.yml b/.github/workflows/issue_comment_edited.yml index ae518daed3..1b9f80c6bb 100644 --- a/.github/workflows/issue_comment_edited.yml +++ b/.github/workflows/issue_comment_edited.yml @@ -4,6 +4,10 @@ on: issue_comment: types: [edited] +concurrency: + group: ${{ github.workflow }}-${{ github.event.comment.id }} + cancel-in-progress: true + jobs: check-pr-labels: if: ${{ github.event.issue.pull_request }} @@ -30,14 +34,14 @@ jobs: - name: Install PyGithub run: pip install -Uq PyGithub - - name: Assign issue - id: assign + - name: Label PR + id: label_out run: python build_tools/comment_pr_labeler.py env: CONTEXT_GITHUB: ${{ toJson(github) }} # GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} - - if: ${{ steps.assign.outputs.empty_commit }} + - if: ${{ steps.label_out.outputs.empty_commit == 'true' }} name: Checkout head uses: actions/checkout@v4 with: @@ -45,11 +49,10 @@ jobs: ref: ${{ github.head_ref }} # token: ${{ steps.app-token.outputs.token }} - - if: ${{ steps.assign.outputs.empty_commit }} + - if: ${{ steps.label_out.outputs.empty_commit == 'true' }} name: Push empty commit uses: stefanzweifel/git-auto-commit-action@v5 with: - branch: ${{ steps.assign.outputs.branch }} commit_message: Empty commit for CI commit_user_name: aeon-actions-bot[bot] commit_options: --allow-empty diff --git a/build_tools/comment_pr_labeler.py b/build_tools/comment_pr_labeler.py index 8158932fca..e3c2082b20 100644 --- a/build_tools/comment_pr_labeler.py +++ b/build_tools/comment_pr_labeler.py @@ -17,13 +17,12 @@ comment_user = context_dict["event"]["comment"]["user"]["login"] labels = [label.name for label in issue.get_labels()] -# if comment_user != "aeon-actions-bot[bot]" or issue.pull_request is None: -# print("::set-output name=empty_commit::false") # noqa: T201 +# if issue.pull_request is None or comment_user != "aeon-actions-bot[bot]" or "## Thank you for contributing to `aeon`" not in comment.body: +# with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: +# print(f"empty_commit=false", file=fh) # noqa: T201 # sys.exit(0) pr = issue.as_pull_request() -print(f"::set-output name=branch::{pr.head.label}") # noqa: T201 - def check_label_option(label, option): """Add or remove a label based on a checkbox in a comment.""" @@ -51,7 +50,10 @@ def check_label_option(label, option): if "- [x] Push an empty commit to re-run CI checks" in comment_body: for comment in pr.get_comments(): - if comment.user.login == comment_user and comment_body in comment.body: + if ( + comment.user.login == comment_user + and "## Thank you for contributing to `aeon`" in comment.body + ): comment.edit( comment_body.replace( "- [x] Push an empty commit to re-run CI checks", @@ -59,6 +61,8 @@ def check_label_option(label, option): ) ) break - print("::set-output name=empty_commit::true") # noqa: T201 + with open(os.environ["GITHUB_OUTPUT"], "a") as fh: + print(f"empty_commit=true", file=fh) # noqa: T201 else: - print("::set-output name=empty_commit::false") # noqa: T201 + with open(os.environ["GITHUB_OUTPUT"], "a") as fh: + print(f"empty_commit=false", file=fh) # noqa: T201