-
-
Notifications
You must be signed in to change notification settings - Fork 23
88 lines (80 loc) · 2.85 KB
/
dependency-pr-comment.yml
File metadata and controls
88 lines (80 loc) · 2.85 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
---
name: Comment on dependency PRs
# yamllint disable-line rule:truthy
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
inputs:
pull_request_number:
description: Pull request number to inspect
required: true
type: number
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || inputs.pull_request_number || github.ref }}
cancel-in-progress: true
jobs:
comment:
name: Comment on dependency-only PRs
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: read
steps:
- name: Resolve pull request
id: pull-request
uses: actions/github-script@v9
with:
script: |
const pullRequest = context.payload.pull_request ?? (
await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: Number("${{ inputs.pull_request_number || 0 }}"),
})
).data;
core.setOutput("number", String(pullRequest.number));
core.setOutput("base_sha", pullRequest.base.sha);
core.setOutput("head_sha", pullRequest.head.sha);
core.setOutput("head_repo_owner", pullRequest.head.repo.owner.login);
core.setOutput("head_repo_name", pullRequest.head.repo.name);
- name: Check out workflow source
uses: actions/checkout@v6
- name: Check out pull request base
uses: actions/checkout@v6
with:
ref: ${{ steps.pull-request.outputs.base_sha }}
path: .dependency-pr-comment-base
- name: Create or update dependency comment
uses: actions/github-script@v9
with:
script: |
const { pathToFileURL } = await import("node:url");
const moduleUrl = pathToFileURL(`${process.cwd()}/.github/scripts/dependency-pr-comment.js`).href;
const { default: commentOnDependencyPr } = await import(moduleUrl);
await commentOnDependencyPr({
github,
context,
core,
repositoryRoot: `${process.cwd()}/.dependency-pr-comment-base`,
pullRequest: {
number: Number("${{ steps.pull-request.outputs.number }}"),
base: {
sha: "${{ steps.pull-request.outputs.base_sha }}",
},
head: {
sha: "${{ steps.pull-request.outputs.head_sha }}",
repo: {
owner: {
login: "${{ steps.pull-request.outputs.head_repo_owner }}",
},
name: "${{ steps.pull-request.outputs.head_repo_name }}",
},
},
},
});