Skip to content

Commit

Permalink
feat: react with a rocket (#176)
Browse files Browse the repository at this point in the history
* feat: react with a rocket

* fix: try not equal null

* fix: wrong path

* need conda env

* try a new commit

* fix: use it as an issue
  • Loading branch information
beckermr authored Sep 25, 2024
1 parent 6bc318f commit e5ed8f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
17 changes: 16 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ runs:
shell: bash -leo pipefail {0}
run: |
if [[ "${EVENT_NAME}" == "issue_comment" ]]; then
if [[ "${HAS_RELOCK_SLUG}" == "false" ]]; then
if [[ "${HAS_RELOCK_SLUG}" == "false" || "${COMMENT_IS_PR}" == "false" ]]; then
res="true"
else
res="false"
Expand Down Expand Up @@ -108,6 +108,7 @@ runs:
INPUT_ACTION: ${{ inputs.action }}
EVENT_NAME: ${{ github.event_name }}
HAS_RELOCK_SLUG: ${{ startsWith(github.event.comment.body, '/relock-conda') }}
COMMENT_IS_PR: ${{ github.event.issue.pull_request != null }}

- name: setup conda-lock
if: ${{ steps.check.outputs.skip != 'true' }}
Expand All @@ -125,6 +126,20 @@ runs:
channels:
- conda-forge
- name: react to PR
if: >-
steps.check.outputs.skip != 'true'
&& github.event_name == 'issue_comment'
&& startsWith(github.event.comment.body, '/relock-conda')
shell: bash -leo pipefail {0}
run: |
python ${{ github.action_path }}/react.py \
--full-name "${{ github.repository }}" \
--pr-number "${{ github.event.issue.number }}" \
--comment-id "${{ github.event.comment.id }}"
env:
GH_TOKEN: ${{ inputs.github-token }}

- name: checkout PR if running on an issue
if: >-
steps.check.outputs.skip != 'true'
Expand Down
20 changes: 20 additions & 0 deletions react.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

import click
import github


@click.command()
@click.option("--full-name", required=True, type=str)
@click.option("--pr-number", required=True, type=int)
@click.option("--comment-id", required=True, type=int)
def main(full_name, pr_number, comment_id):
gh = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
repo = gh.get_repo(full_name)
pr_as_issue = repo.get_pull(pr_number).as_issue()
comment = pr_as_issue.get_comment(comment_id)
comment.create_reaction("rocket")


if __name__ == "__main__":
main()

0 comments on commit e5ed8f8

Please sign in to comment.