-
Notifications
You must be signed in to change notification settings - Fork 8
80 lines (79 loc) · 3.17 KB
/
update-cmd-repositories.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
70
71
72
73
74
75
76
77
78
79
80
---
name: Update dependent repositories
on:
push:
branches:
- master
jobs:
update-dependent-repositories:
strategy:
matrix:
repository:
- cmd-registry-proxy-dns
- cmd-nsc
- cmd-registry-memory
- cmd-nsmgr
- cmd-forwarder-vppagent
- cmd-exclude-prefixes-k8s
- cmd-forwarder-sriov
- cmd-nse-icmp-responder
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
if: github.repository == 'networkservicemesh/cmd-template'
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/gh-find-current-pr@v1
id: findPr
with:
github-token: ${{ github.token }}
- name: Create commit message
working-directory: ${{ github.repository }}
run: |
echo "Update common CI files to latest version from ${{ github.repository }}@master ${{ github.repository }}#${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message
echo "" >> /tmp/commit-message
echo "${{ github.repository }} PR link: https://github.com/${{ github.repository }}/pull/${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message
echo "" >> /tmp/commit-message
echo "${{ github.repository }} commit message:" >> /tmp/commit-message
git log -1 >> /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.15
- 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 "nsmbot@networkservicmesh.io"
git config --global user.name "NSMBot"
git remote add cmd_template https://github.com/networkservicemesh/cmd-template.git
git fetch cmd_template
if [ ! -f .templateignore ]; then
touch .templateignore
git add .templateignore
fi
git diff cmd_template/master -R | git apply
git add $(git ls-tree --name-only -r cmd_template/master | grep ".*\.yml\|.*\.yaml\|.*\.md\|.*\.txt\|.*.\.conf")
git restore -- .templateignore
while read -r line || [[ -n "$line" ]]; do
git restore --staged -- $line
git restore -- $line
done < .templateignore
if ! [ -n "$(git diff --cached --exit-code)" ]; then
exit 0;
fi
git commit -s -F /tmp/commit-message
git checkout -b update/${{ github.repository }}
git push -f origin update/${{ github.repository }}