-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (35 loc) · 1.36 KB
/
run-workflow-on-comment.yaml
File metadata and controls
36 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
on: issue_comment
jobs:
pr_commented:
# This job only runs for pull request comments
name: PR comment
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, 'knowl:rerun_workflow') }}
runs-on: ubuntu-latest
steps:
- run: |
echo A comment on PR $PR_NUMBER - $COMMENT_BODY
env:
PR_NUMBER: ${{ github.event.issue.number }}
COMMENT_BODY: ${{ github.event.comment.body }}
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: |
pip install requests
- uses: jannekem/run-python-script-action@v1
with:
script: |
import requests
import os
git_token = os.getenv("GITHUB_TOKEN")
pull_number = os.getenv("GITHUB_PULL_NUMBER")
repository = os.getenv("GITHUB_REPO")
owner, repo_name = repository.split("/")
url = f"https://api.github.com/repos/{owner}/{repo_name}/actions/runs/4259051604/rerun"
headers = {"Authorization": f"Bearer {git_token}", "Accept": "application/vnd.github+json"}
response = requests.post(url=url, headers=headers)
print(response.content)
env:
GITHUB_TOKEN: ${{github.token}}
GITHUB_PULL_NUMBER: ${{github.event.number}}
GITHUB_REPO: ${{github.repository}}