-
-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (81 loc) · 3.78 KB
/
pull-request.yml
File metadata and controls
92 lines (81 loc) · 3.78 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
#
# https://frontside.com/blog/2020-05-26-github-actions-pull_request/#how-do-workflows-trigger-on-pull_request
#
# | type | description |
# | ---------------------- | ----------------------------------------------------- |
# | assigned | a user is assigned to the pull request |
# | unassigned | a user is unassigned from the pull request |
# | labeled | a label is applied to the pull request |
# | unlabeled | a label is removed from the pull request |
# | opened | pull request is created |
# | edited | title, body, or the base branch of the PR is modified |
# | closed | pull request is closed (as opposed to merged) |
# | reopened | closed pull request is reopened |
# | synchronize | commit(s) pushed to the pull request |
# | ready_for_review | pull request is taken out from draft mode |
# | locked | pull request is locked |
# | unlocked | pull request is unlocked |
# | review_requested | request a user for review |
# | review_request_removed | remove request from user for review |
name: Pull Request
on:
pull_request:
# defaults to opened, synchronize, reopened
types: [opened, synchronize, reopened, closed, edited]
jobs:
pull-request:
runs-on: ubuntu-latest
steps:
- name: github.event_name
run: echo '${{ github.event_name }}'
- name: github.base_ref (target branch)
run: echo '${{ github.base_ref }}'
- name: github.head_ref (source branch)
run: echo '${{ github.head_ref }}'
- name: github.event.pull_request.title (PR title)
if: github.event_name == 'pull_request'
run: echo '${{ github.event.pull_request.title }}'
- name: github.event.number (PR number)
if: github.event_name == 'pull_request'
run: echo '${{ github.event.number }}'
- name: github.event.action (activity type)
run: echo '${{ github.event.action }}'
- name: github.event.pull_request
if: github.event_name == 'pull_request'
run: echo '${{ toJson(github.event.pull_request) }}'
continue-on-error: true
pull-request-comment:
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs#example-setting-permissions-for-a-specific-job
permissions:
pull-requests: write
steps:
# https://github.com/actions/github-script#comment-on-an-issue
- name: Add comment to opened PR
if: github.event.action == 'opened'
uses: actions/github-script@v8
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Thanks for reporting!'
})
# https://cli.github.com/manual/gh_pr_comment
- name: Checkout
uses: actions/checkout@v6
- name: Add comment to PR
run: gh pr comment ${{ github.event.number }} --body '[Hi from GitHub CLI](https://cli.github.com/manual/gh_pr_comment)'
env:
GITHUB_TOKEN: ${{ github.token }}
pull-request-merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: PR merged
run: echo 'PR merged'
- name: github.event.pull_request
run: echo '${{ toJson(github.event.pull_request) }}'
continue-on-error: true