Skip to content

Commit

Permalink
Merge pull request #138 from denis-tingaikin/add-update-deps-job
Browse files Browse the repository at this point in the history
feat: add update deps job for deployments-k8s
  • Loading branch information
edwarnicke authored Jan 31, 2021
2 parents edb89e8 + f43ecd5 commit 4b51e42
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,78 @@ jobs:
with:
GITHUB_LOGIN: nsmbot
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-dependent-repositories:
strategy:
matrix:
repository:
- integration-tests
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
needs:
- automerge
if: github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request'
steps:
- name: Setup envs
run: |
echo GOPATH=$GITHUB_WORKSPACE >> $GITHUB_ENV
echo GO111MODULE=on >> $GITHUB_ENV
echo $GITHUB_WORKSPACE/bin >> $GITHUB_PATH
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.workspace }}/src/github.com/${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Install gotestmd
run: "go get github.com/networkservicemesh/gotestmd"
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
- name: Install goimports
run: "go get golang.org/x/tools/cmd/goimports"
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
- name: Checkout networkservicemesh/${{ matrix.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
repository: networkservicemesh/${{ matrix.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- uses: actions/setup-go@v1
with:
go-version: 1.15
- name: Update ${{ github.repository }} locally
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
GOPRIVATE=github.com/networkservicemesh go get -u github.com/${{ github.repository }}
go generate ./...
go mod tidy
git diff
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 8
- name: Find and Replace version
uses: jacobtomlinson/gha-find-replace@master
with:
find: "s.Version =.*\n"
replace: "$s.Version =${{ steps.short-sha.outputs.sha }}\n"
- name: Push update to the ${{ matrix.repository }}
working-directory: ${{ github.workspace }}/src/github.com/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 add -- .
if ! [ -n "$(git diff --cached --exit-code)" ]; then
echo ${{ matrix.repository }} is up to date
exit 0;
fi
echo "Update go.mod and go.sum to latest version from ${{ github.repository }}@main ${{ github.repository }}#${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message
echo "" >> /tmp/commit-message
echo "${{ github.repository }} PR link: https://github.com/${{ github.repository }}/pull/${{ github.event.number }}" >> /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
git commit -s -F /tmp/commit-message
git checkout -b update/${{ github.repository }}
git push -f origin update/${{ github.repository }}
84 changes: 84 additions & 0 deletions .github/workflows/update-dependent-repositories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: Update dependent repositories
on:
push:
branches:
- main
jobs:
update-dependent-repositories:
strategy:
matrix:
repository:
- integration-tests
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
steps:
- name: Setup envs
run: |
echo GOPATH=$GITHUB_WORKSPACE >> $GITHUB_ENV
echo GO111MODULE=on >> $GITHUB_ENV
echo $GITHUB_WORKSPACE/bin >> $GITHUB_PATH
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.workspace }}/src/github.com/${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Install gotestmd
run: "go get github.com/networkservicemesh/gotestmd"
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
- name: Install goimports
run: "go get golang.org/x/tools/cmd/goimports"
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
- name: Find merged PR
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
github-token: ${{ github.token }}
- name: Checkout networkservicemesh/${{ matrix.repository }}
uses: actions/checkout@v2
with:
path: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
repository: networkservicemesh/${{ matrix.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- uses: actions/setup-go@v1
with:
go-version: 1.15
- name: Update ${{ github.repository }} locally
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
GOPRIVATE=github.com/networkservicemesh go get -u github.com/${{ github.repository }}
go generate ./...
go mod tidy
git diff
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 8
- name: Find and Replace version
uses: jacobtomlinson/gha-find-replace@master
with:
find: "s.Version =.*\n"
replace: "$s.Version =${{ steps.short-sha.outputs.sha }}\n"
- name: Push update to the ${{ matrix.repository }}
working-directory: ${{ github.workspace }}/src/github.com/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 add -- .
if ! [ -n "$(git diff --cached --exit-code)" ]; then
echo ${{ matrix.repository }} is up to date
exit 0;
fi
echo "Update go.mod and go.sum to latest version from ${{ github.repository }}@main ${{ 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
git commit -s -F /tmp/commit-message
git checkout -b update/${{ github.repository }}
git push -f origin update/${{ github.repository }}

0 comments on commit 4b51e42

Please sign in to comment.