-
Notifications
You must be signed in to change notification settings - Fork 156
74 lines (67 loc) · 2.25 KB
/
submodule-update.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
---
name: Submodule Updates
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
push:
branches: [develop]
schedule:
- cron: '0 12 * * *'
jobs:
check_submodules:
name: Pull Request for updated submodules
runs-on: ubuntu-latest
env:
PARENT_REPOSITORY: 'EDCD/EDMarketConnector'
CHECKOUT_BRANCH: 'develop'
PR_AGAINST_BRANCH: 'develop'
OWNER: 'EDCD'
steps:
- uses: actions/checkout@v4
with:
ref: '${{ env.CHECKOUT_BRANCH }}'
submodules: true
- name: Update submodules
shell: bash
run: |
git config user.name github-actions
git config user.email [email protected]
git submodule update --remote
- name: Check for changes
id: check_for_changes
continue-on-error: true
run: |
changes=$(git status --porcelain)
git status --porcelain
if [ -n "${changes}" ];
then
echo 'changes=true' >> $GITHUB_OUTPUT
echo "changes_text=${changes}" >> $GITHUB_OUTPUT
else
echo 'changes=false' >> $GITHUB_OUTPUT
fi
exit 0
- name: Create submodules changes branch
if: steps.check_for_changes.outputs.changes == 'true'
run: |
git checkout -b "submodule-change/$GITHUB_RUN_ID" $CHECKOUT_BRANCH
git commit -am "updating submodules"
git push --set-upstream origin "submodule-change/$GITHUB_RUN_ID"
- name: Create pull request against target branch
if: steps.check_for_changes.outputs.changes == 'true'
uses: actions/github-script@v7
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
await github.rest.pulls.create({
owner: '${{ github.repository_owner }}',
repo: '${{ github.repository }}'.split('/')[1].trim(),
head: 'submodule-change/${{ github.run_id }}',
base: '${{ env.PR_AGAINST_BRANCH }}',
title: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
body: '${{ steps.check_for_changes.outputs.changes_text }}',
});