-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
47 lines (41 loc) · 1.41 KB
/
helper.yml
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
name: Post Merged.md on PR Close
on:
pull_request_target:
types:
- closed
jobs:
post-merged-md:
runs-on: ubuntu-latest
steps:
# Check if the PR was merged
- id: create_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
- name: Check if PR was merged
id: pr-merge-check
uses: actions/github-script@v7
with:
script: |
return context.payload.pull_request.merged
# Fetch merged.md content if PR was merged
- name: Fetch merged.md content
if: steps.pr-merge-check.outputs.result == 'true'
run: |
curl -o merged.md https://raw.githubusercontent.com/open-domains/.github/main/merged.md
# Post the content of merged.md as a comment using the custom token
- name: Post comment on PR
if: steps.pr-merge-check.outputs.result == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ steps.create_token.outputs.token }}
script: |
const fs = require('fs');
const content = fs.readFileSync('merged.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: content
});