-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
104 lines (97 loc) · 3.29 KB
/
action.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: 'GitHub Action Submodule Updates'
description: 'Update submodules and creates new pull request against parent repository'
author: 'releasehub'
branding:
icon: 'git-pull-request'
color: 'yellow'
inputs:
github_token:
description: 'Github Token'
required: true
checkout_branch:
description: 'Branch to checkout'
required: false
default: 'main'
pr_against_branch:
description: 'Parent branch'
required: true
parent_repository:
description: 'Parent Repository'
required: true
owner:
description: 'Owner'
required: true
label:
description: 'Create Release Environment label'
required: false
default: 'Create Release Environment'
reviewer:
description: 'Reviewer'
required: false
runs:
using: 'composite'
steps:
- name: Checkout parent repository and branch
uses: actions/checkout@v3
with:
token: ${{ inputs.github_token }}
repository: ${{ inputs.parent_repository }}
ref: ${{ inputs.checkout_branch }}
submodules: true
fetch-depth: 0
- name: Create new branch and push changes
shell: bash
run: |
git config user.name github-actions
git config user.email [email protected]
git submodule update --remote
git checkout -b $GITHUB_RUN_ID
git commit -am "updating submodules"
git push --set-upstream origin $GITHUB_RUN_ID
- name: Create pull request against target branch
uses: actions/github-script@v6
with:
github-token: ${{ inputs.github_token }}
script: |
await github.rest.pulls.create({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
head: process.env.GITHUB_RUN_ID,
base: '${{ inputs.pr_against_branch }}',
title: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
body: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
});
- name: Add labels
uses: actions/github-script@v6
with:
github-token: ${{ inputs.github_token }}
script: |
const res = await github.rest.issues.listForRepo({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
});
const pr = res.data.filter(i => i.title.includes(process.env.GITHUB_RUN_ID));
const prNumber = pr[0].number;
await github.rest.issues.addLabels({
issue_number: prNumber,
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
labels: ['${{ inputs.label }}']
});
- name: Add reviewers
uses: actions/github-script@v6
with:
github-token: ${{ inputs.github_token }}
script: |
const res = await github.rest.issues.listForRepo({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
});
const pr = res.data.filter(i => i.title.includes(process.env.GITHUB_RUN_ID));
const prNumber = pr[0].number;
await github.rest.pulls.requestReviewers({
pull_number: prNumber,
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
reviewers: ${{ inputs.reviewer }}
});