Skip to content

Commit

Permalink
Merge pull request #742 from denis-tingaikin/fix-automerge-dont-work
Browse files Browse the repository at this point in the history
fix: automerge job doesn't work on ci
  • Loading branch information
edwarnicke authored Apr 12, 2021
2 parents f38745e + 27f8175 commit dd064ad
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 92 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/automerge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
name: automerge
on:
workflow_run:
types:
- completed
workflows:
- 'ci'
jobs:
automerge:
name: Automerge
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' }}
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Fetch main
run: |
git remote -v
git fetch --depth=1 origin main
- name: Only allow go.mod, go.sum, *.gen.go files
run: |
find . -type f ! -name '*.yaml' ! -name '*.yml' -exec git diff --exit-code origin/main -- {} +
- name: Merge PR
uses: ridedott/merge-me-action@master
with:
GITHUB_LOGIN: nsmbot
ENABLED_FOR_MANUAL_CHANGES: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAXIMUM_RETRIES: 25
update-dependent-repositories:
strategy:
matrix:
repository:
- integration-tests
name: Update ${{ matrix.repository }}
runs-on: ubuntu-latest
needs:
- automerge
if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' }}
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 ${{ matrix.repository }} locally
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
go generate ./...
go mod tidy
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 8
- name: Push update to the ${{ matrix.repository }}
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
sed -r -i 's/(s\.checkout\.Version =.*)/s.checkout.Version = "${{ steps.short-sha.outputs.sha }}"/g' extensions/base/suite.go
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 }}
92 changes: 0 additions & 92 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,95 +19,3 @@ jobs:
with:
config_file: .yamllint.yml
strict: true

automerge:
name: automerge
runs-on: ubuntu-latest
needs:
- yamllint
if: github.actor == 'nsmbot' && github.event_name == 'pull_request'
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Fetch main
run: |
git remote -v
git fetch --depth=1 origin main
- name: Only allow go.mod and go.sum changes
run: |
find . -type f ! -name '*.yaml' ! -name '*.yml' -exec git diff --exit-code origin/main -- {} +
- name: Automerge nsmbot PR
uses: ridedott/merge-me-action@master
with:
GITHUB_LOGIN: nsmbot
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAXIMUM_RETRIES: 10
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 == 'main' && 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 ${{ matrix.repository }} locally
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
go generate ./...
go mod tidy
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 8
- name: Push update to the ${{ matrix.repository }}
working-directory: ${{ github.workspace }}/src/github.com/networkservicemesh/${{ matrix.repository }}
run: |
sed -r -i 's/(s\.checkout\.Version =.*)/s.checkout.Version = "${{ steps.short-sha.outputs.sha }}"/g' extensions/base/suite.go
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 dd064ad

Please sign in to comment.