forked from justin-ys/github-action-pr-expanded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
73 lines (68 loc) · 2.26 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
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
submodule_path:
description: 'Location of submodule in parent repo relative to root'
required: true
owner:
description: 'Owner'
required: true
pr_title:
description: 'Title of pull request'
required: false
default: '[Auto-generated] Submodule Updates for ${{ github.repository }} (${{ github.run_id }})'
pr_description:
description: 'Description of pull request'
required: false
default: 'Updates submodule ${{ github.repository }}'
runs:
using: 'composite'
steps:
- name: Checkout parent repository and branch
uses: actions/checkout@v4
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 "${{ inputs.submodule_path }}"
git add "${{ inputs.submodule_path }}"
git checkout -b "${{ github.repository }}-$GITHUB_RUN_ID"
git commit -m "updating submodules"
git push --set-upstream origin "${{ github.repository }}-$GITHUB_RUN_ID"
- name: Create pull request against target branch
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github_token }}
script: |
await github.rest.pulls.create({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
head: '${{ github.repository }}-${{ github.run_id }}',
base: '${{ inputs.pr_against_branch }}',
title: '${{ inputs.pr_title }}',
body: '${{ inputs.pr_description }}',
});