Skip to content

Commit

Permalink
Update from update/networkservicemesh/cmd-template
Browse files Browse the repository at this point in the history
  • Loading branch information
nsmbot authored Dec 1, 2020
1 parent 0dc5d8d commit b044fc4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 53 deletions.
56 changes: 38 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ jobs:
config_file: .yamllint.yml
strict: true

shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: shellcheck
uses: fkautz/shell-linter@v1.0.1

build:
name: build
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -65,7 +73,7 @@ jobs:
- uses: actions/checkout@v2
- name: Restrict dependencies on github.com/networkservicemesh/*
env:
ALLOWED_REPOSITORIES: "sdk, api, sdk-vpp"
ALLOWED_REPOSITORIES: "sdk, api, sdk-k8s, sdk-vppagent, sdk-sriov"
run: |
for i in $(grep github.com/networkservicemesh/ go.mod | grep -v '^module' | sed 's;.*\(github.com\/networkservicemesh\/[^ ]*\).*;\1;g');do
if ! [ "$(echo ${ALLOWED_REPOSITORIES} | grep ${i#github.com/networkservicemesh/})" ]; then
Expand Down Expand Up @@ -93,13 +101,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/setup-protoc@master
with:
version: '3.8.0'
- uses: actions/setup-go@v1
with:
go-version: 1.15
- name: Install proto-gen-go
run: go get -u github.com/golang/protobuf/protoc-gen-go@v1.3.3
- name: Install proto-gen-go
run: go get github.com/searKing/golang/tools/cmd/go-syncmap
- name: Generate files
run: go generate ./...
- name: Check for changes in generated code
run: |
git diff -- '*.pb.go' || ( echo "Rerun go generate ./... locally and resubmit" && false )
git diff -- '*.gen.go' || ( echo "Rerun go generate ./... locally and resubmit" && false )
excludereplace:
Expand Down Expand Up @@ -206,6 +222,23 @@ jobs:
path: ${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Create branch name
working-directory: ${{ github.repository }}
run: |
diff=$(git diff --name-only)
BRANCH_NAME="${{ github.event.repository.name }}"
if [[ $(grep "go.mod" <<< "${diff}") && $(grep "" -c <<< "${diff}") == 2 ]]; then
sdkPattern="github.com\/networkservicemesh\/sdk "
sdkVersion=$(grep --regexp "${sdkPattern}" go.mod)
BRANCH_NAME="${sdkVersion:${#sdkPattern}}"
else
{
git push origin --delete update/"${BRANCH_NAME}"
} || {
echo Branch update/"${BRANCH_NAME}" is already deleted
}
fi;
echo BRANCH_NAME=${BRANCH_NAME} >> $GITHUB_ENV
- name: Create commit message
working-directory: ${{ github.repository }}
run: |
Expand Down Expand Up @@ -241,24 +274,11 @@ jobs:
echo Repository already up to date
exit 0;
fi
diff=$(git diff --name-only)
branchName="${{ github.event.repository.name }}"
if [[ $(grep "go.mod" <<< "${diff}") && $(grep "" -c <<< "${diff}") == 2 ]]; then
sdkPattern="github.com\/networkservicemesh\/sdk "
sdkVersion=$(grep --regexp "${sdkPattern}" go.mod)
branchName="${sdkVersion:${#sdkPattern}}"
else
{
git push origin --delete update/"${branchName}"
} || {
echo Branch update/"${branchName}" is already deleted
}
fi;
git config --global user.email "nsmbot@networkservicmesh.io"
git config --global user.name "NSMBot"
git commit -s -F /tmp/commit-message
git checkout -b update/"${branchName}"
while [ $(git push origin update/"${branchName}") ]; do
git fetch origin update/"${branchName}"
git rebase origin/update/"${branchName}"
git checkout -b update/"${BRANCH_NAME}"
while [ $(git push origin update/"${BRANCH_NAME}") ]; do
git fetch origin update/"${BRANCH_NAME}"
git rebase origin/update/"${BRANCH_NAME}"
done
2 changes: 1 addition & 1 deletion .github/workflows/pr-for-updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- update/**
jobs:
auto-pull-request:
name: Pull Request on update/* Branch Push
name: Pull Request on update/sync Branch Push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: Update integration-k8s-kind reposiotry
name: Update deployments-k8s reposiotry
on:
push:
branches:
- master

jobs:
update-integration-k8s-kind:
name: Update integration-k8s-kind
update-deployments-k8s:
name: Update deployments-k8s
runs-on: ubuntu-latest
if: github.repository != 'networkservicemesh/cmd-template'
steps:
Expand All @@ -17,6 +17,16 @@ jobs:
path: ${{ github.repository }}
repository: ${{ github.repository }}
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 8
- name: Checkout networkservicemesh/deployments-k8s
uses: actions/checkout@v2
with:
path: networkservicemesh/deployments-k8s
repository: networkservicemesh/deployments-k8s
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- name: Create commit message
working-directory: ${{ github.repository }}
run: |
Expand All @@ -28,48 +38,22 @@ jobs:
git log -1 >> /tmp/commit-message
echo "Commit Message:"
cat /tmp/commit-message
- name: Checkout networkservicemesh/integration-k8s-kind
uses: actions/checkout@v2
with:
path: networkservicemesh/integration-k8s-kind
repository: networkservicemesh/integration-k8s-kind
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
- 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: "${{ github.event.repository.name }}:.*\n"
replace: "${{ github.event.repository.name }}:${{ steps.short-sha.outputs.sha }}\n"
- name: Push update to the integration-k8s-kind
working-directory: networkservicemesh/integration-k8s-kind
- name: Push update to the deployments-k8s
working-directory: networkservicemesh/deployments-k8s
run: |
echo Starting to update repositotry integration-k8s-kind
echo Starting to update repositotry deployments-k8s
git add -- .
if ! [ -n "$(git diff --cached --exit-code)" ]; then
echo Repository already up to date
exit 0;
fi
diff=$(git diff --name-only)
branchName="${{ github.event.repository.name }}"
if [[ $(grep "go.mod" <<< "${diff}") && $(grep "" -c <<< "${diff}") == 2 ]]; then
sdkPattern="github.com\/networkservicemesh\/sdk "
sdkVersion=$(grep --regexp "${sdkPattern}" go.mod)
branchName="${sdkVersion:${#sdkPattern}}"
else
{
git push origin --delete update/"${branchName}"
} || {
echo Branch update/"${branchName}" is already deleted
}
fi;
git config --global user.email "nsmbot@networkservicmesh.io"
git config --global user.name "NSMBot"
git commit -s -F /tmp/commit-message
git checkout -b update/"${branchName}"
while [ $(git push origin update/"${branchName}") ]; do
git fetch origin update/"${branchName}"
git rebase origin/update/"${branchName}"
done
git checkout -b update/${{ github.repository }}
git push -f origin update/${{ github.repository }}

0 comments on commit b044fc4

Please sign in to comment.