Skip to content

Commit

Permalink
empty commit 7 (#21)
Browse files Browse the repository at this point in the history
* comment

* remove branch param

* fixes
  • Loading branch information
MatthewMiddlehurst authored Jul 4, 2024
1 parent 1676ed7 commit d99e2a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/issue_comment_edited.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -30,26 +34,25 @@ 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:
repository: ${{ github.event.pull_request.head.repo.full_name }}
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
Expand Down
18 changes: 11 additions & 7 deletions build_tools/comment_pr_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -51,14 +50,19 @@ 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",
"- [ ] Push an empty commit to re-run CI checks",
)
)
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

0 comments on commit d99e2a5

Please sign in to comment.