Skip to content

Commit

Permalink
fix(samples): activate start_github_action and update repo to `re…
Browse files Browse the repository at this point in the history
…pository` per eng-1631 (#117)

**Issues Addressed:**
- The `start_github_action` trigger function was previously commented
out to encourage users to configure the workflow file before running the
sample. This was relevant before cloud, where the `.yaml` file was
easily accessible, which is no longer the case. The solution is to keep
the trigger function active from the start. I updated the docstring to
include clear instructions reflecting this change.
- The push event was not received from the app because push events were
not activated in the app configuration.
- Per ENG-1631, I updated instances of `repo` to `repository` to align
with how GitHub structures JSON event data.
  • Loading branch information
pashafateev authored Dec 2, 2024
1 parent 4b10c6d commit fb34bd6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
9 changes: 4 additions & 5 deletions samples/github/autokitteh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ project:
connection: github_conn
event_type: workflow_run
call: workflow.py:on_github_workflow_run
# Uncomment the following trigger:
# - name: github_push
# connection: github_conn
# event_type: push
# call: workflow.py:start_github_action
- name: github_push
connection: github_conn
event_type: push
call: workflow.py:start_github_action
27 changes: 10 additions & 17 deletions samples/github/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@
def start_github_action(event):
"""Start a GitHub action workflow.
See the following link for more information:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
This function is preconfigured as the entry point for an AutoKitteh trigger.
It will function correctly once a named workflow YAML file is created in a
relevant GitHub repository under the ".github/workflows" directory.
This function is preconfigured as the entry-point for an AutoKitteh trigger,
but it's currently commented out in the "autokitteh.yaml" file. To activate it,
uncomment the following lines:
# - name: github_push
# connection: github_conn
# event_type: push
# call: workflow.py:start_github_action
Additionally, it requires a named workflow YAML file to be present in a relevant GitHub repository.
Example workflow YAML file (in the repo's ".github/workflows" directory):
Example workflow YAML file:
on: workflow_dispatch
jobs:
Expand All @@ -29,12 +19,15 @@ def start_github_action(event):
steps:
- run: echo "Do stuff"
To fully utilize this trigger, ensure the workflow file is named appropriately
(e.g., "dispatch.yml") and is configured for the intended events.
Args:
event: GitHub event data (e.g. new pull request or push event).
event: GitHub event data (e.g., a new pull request or push event).
"""
repo = event.data.repo.full_name
repo = event.data.repository.full_name
# TODO: ENG-1631
ref = event.data.repo.default_branch # Branch name or tag
ref = event.data.repository.default_branch # Branch name or tag
workflow_file = "dispatch.yml" # .github/workflows/dispatch.yml

g = github_client("github_conn")
Expand Down

0 comments on commit fb34bd6

Please sign in to comment.