forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 39
69 lines (66 loc) · 2.33 KB
/
weekly-dependencies-pr.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
actions: none
checks: none
contents: none
deployments: none
id-token: none
# This action can update/close issues
issues: write
discussions: none
packages: none
pages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none
on:
push:
branches:
- weekly-dependency-updates
paths:
- 'Gemfile.lock'
name: Weekly dependency PR workflow
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- name: Create Pull Request
uses: actions/github-script@v6
with:
script: |
const { repo, owner } = context.repo;
console.log('repo:');
console.log(JSON.stringify(repo, null, 4));
console.log('owner:');
console.log(JSON.stringify(owner, null, 4));
const hasPR = await github.rest.pulls.list({
owner,
repo,
head: owner + ':' + '${{ github.ref_name }}'
});
console.log('hasPR:');
console.log(JSON.stringify({ data: hasPR.data, status: hasPR.status }, null, 4));
if (Array.isArray(hasPR.data) && !hasPR.data.length) {
const result = await github.rest.pulls.create({
title: 'Weekly dependency updates',
owner,
repo,
head: '${{ github.ref_name }}',
base: 'master',
body: [
'This PR is auto-generated by [actions/github-script](https://github.com/actions/github-script). ',
'`bundle update` revealed the following gems have new version to be evaluated for update.'
].join('\n')
});
console.log('result:');
console.log(JSON.stringify({ data: result.data, status: result.status }, null, 4));
const labelResult = await github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['automation', 'rn-no-release-notes']
});
console.log('labelResult:');
console.log(JSON.stringify({ data: labelResult.data, status: labelResult.status }, null, 4));
}