-
Notifications
You must be signed in to change notification settings - Fork 22
69 lines (68 loc) · 2.81 KB
/
update-dependent-repositories-gomod.yaml
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
---
name: Update dependent repositories
on:
push:
branches:
- main
workflow_run:
types:
- completed
workflows:
- 'automerge'
jobs:
update-dependent-repositories:
strategy:
matrix:
repository: [sdk]
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' || github.event_name == 'push' }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Find merged PR
uses: jwalton/[email protected]
id: findPr
with:
sha: ${{ github.sha }}
github-token: ${{ github.token }}
- name: Create commit message
working-directory: ${{ github.repository }}
run: |
echo "Update go.mod and go.sum to latest version from ${{ github.repository }}@main" >> /tmp/commit-message
echo "PR link: https://github.com/${{ github.repository }}/pull/${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message
echo "" >> /tmp/commit-message
LOG_MSG=$(git log --date=iso --pretty='format:Commit: %h%nAuthor: %an%nDate: %ad%nMessage:%n - %B%n' -1 | sed '/^$/d;$d')
for((i=2;i<=18;i+=2)); do n=$(printf '%*s' $((i+2))) m=$(printf '%*s' $i) LOG_MSG=$(echo "$LOG_MSG" | tr '\n' '|' | sed "s/${m}-/${n}-/2g" | tr '|' '\n'); done
echo "$LOG_MSG" >> /tmp/commit-message
echo "Commit Message:"
cat /tmp/commit-message
- name: Checkout networkservicemesh/${{ matrix.repository }}
uses: actions/checkout@v2
with:
path: networkservicemesh/${{ matrix.repository }}
repository: networkservicemesh/${{ matrix.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- uses: actions/setup-go@v1
with:
go-version: 1.20.5
- name: Update ${{ github.repository }} locally
working-directory: networkservicemesh/${{ matrix.repository }}
run: |
GOPRIVATE=github.com/networkservicemesh go get -u github.com/${{ github.repository }}@main
go mod tidy
git diff
- name: Push update to the ${{ matrix.repository }}
working-directory: networkservicemesh/${{ matrix.repository }}
run: |
echo Starting to update repositotry ${{ matrix.repository }}
git config --global user.email "[email protected]"
git config --global user.name "NSMBot"
git add go.mod go.sum
git commit -s -F /tmp/commit-message
git checkout -b update/${{ github.repository }}
git push -f origin update/${{ github.repository }}