Skip to content

Commit

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

* repo and branch

* comment
  • Loading branch information
MatthewMiddlehurst authored Jul 4, 2024
1 parent 6ec46bd commit 75c9621
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/issue_comment_edited.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: true

jobs:
check-pr-labels:
pr-welcome-edited:
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-20.04

Expand All @@ -34,9 +34,9 @@ jobs:
- name: Install PyGithub
run: pip install -Uq PyGithub

- name: Label PR
- name: Process comment edit
id: label_out
run: python build_tools/comment_pr_labeler.py
run: python build_tools/pr_welcome_edited.py
env:
CONTEXT_GITHUB: ${{ toJson(github) }}
# GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
Expand All @@ -45,8 +45,8 @@ jobs:
name: Checkout head
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
repository: ${{ steps.label_out.outputs.repo }}
ref: ${{ steps.label_out.outputs.branch }}
# token: ${{ steps.app-token.outputs.token }}

- if: ${{ steps.label_out.outputs.empty_commit == 'true' }}
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/pr_precommit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: PR pre-commit

on:
push:
branches:
- main
pull_request_target:
branches:
- main
Expand All @@ -14,19 +17,19 @@ jobs:
runs-on: ubuntu-20.04

steps:
- name: Create app token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.PR_APP_ID }}
private-key: ${{ secrets.PR_APP_KEY }}
# - name: Create app token
# uses: actions/create-github-app-token@v1
# id: app-token
# with:
# app-id: ${{ vars.PR_APP_ID }}
# private-key: ${{ secrets.PR_APP_KEY }}

- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
token: ${{ steps.app-token.outputs.token }}
# token: ${{ steps.app-token.outputs.token }}

- name: Setup Python 3.10
uses: actions/setup-python@v5
Expand All @@ -51,7 +54,7 @@ jobs:
with:
extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }}

- if: ${{ failure() && github.event_name == 'pull_request_target' && github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'stop pre-commit fixes')}}
- if: ${{ failure() && github.event_name == 'pull_request_target' && !github.event.pull_request.draft && !contains(github.event.pull_request.labels.*.name, 'stop pre-commit fixes')}}
name: Push pre-commit fixes
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Labels PRs based on bot comment checkboxes."""
"""Labels PRs and process based on bot comment checkboxes."""

import json
import os
Expand All @@ -17,9 +17,13 @@
comment_user = context_dict["event"]["comment"]["user"]["login"]
labels = [label.name for label in issue.get_labels()]

# 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
# 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("empty_commit=false", file=fh) # noqa: T201
# sys.exit(0)
pr = issue.as_pull_request()

Expand Down Expand Up @@ -48,6 +52,12 @@ def check_label_option(label, option):
for option in label_options:
check_label_option(option[0], option[1])

repo_name = pr.head.repo.full_name
branch_name = pr.head.ref
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
print(f"repo={repo_name}", file=fh) # noqa: T201
print(f"branch={branch_name}", file=fh) # noqa: T201

if "- [x] Push an empty commit to re-run CI checks" in comment_body:
for comment in pr.get_comments():
if (
Expand All @@ -62,7 +72,7 @@ def check_label_option(label, option):
)
break
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
print(f"empty_commit=true", file=fh) # noqa: T201
print("empty_commit=true", file=fh) # noqa: T201
else:
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
print(f"empty_commit=false", file=fh) # noqa: T201
print("empty_commit=false", file=fh) # noqa: T201

0 comments on commit 75c9621

Please sign in to comment.