generated from networkservicemesh/cmd-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Automerge job is not working (#155)
* Sync files with networkservicemesh/cmd-template This PR syncs files with https://github.com/networkservicemesh/cmd-template Revision: https://github.com/networkservicemesh/cmd-template/commits/1edcb77532519c023a21b89529ebdf5fc85e44fc commit 1edcb77532519c023a21b89529ebdf5fc85e44fc Author: Denis Tingaikin <[email protected]> Date: Mon Apr 12 21:10:17 2021 +0700 update cmd-template and fix automerge job (#66) Signed-off-by: denis-tingajkin <[email protected]> Signed-off-by: NSMBot <[email protected]> * fix issues with updating from cmd-template Signed-off-by: Denis Tingaikin <[email protected]> Co-authored-by: NSMBot <[email protected]>
- Loading branch information
1 parent
2b2f3dd
commit 9d4c5bd
Showing
3 changed files
with
84 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
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 master | ||
run: | | ||
git remote -v | ||
git fetch --depth=1 origin master | ||
- name: Only allow go.mod and go.sum changes | ||
run: | | ||
find . -type f ! -name 'go.mod' ! -name 'go.sum' ! -name '*.yaml' ! -name '*.yml' ! -name '*.txt' ! -name '*.md' ! -name '*.conf' -exec git diff --exit-code origin/master -- {} + | ||
- name: Merge PR | ||
uses: ridedott/merge-me-action@master | ||
with: | ||
GITHUB_LOGIN: nsmbot | ||
ENABLED_FOR_MANUAL_CHANGES: true | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
update-deployments-k8s: | ||
name: Update deployments-k8s | ||
runs-on: ubuntu-latest | ||
needs: | ||
- pushImage | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} && github.actor == 'nsmbot' | ||
steps: | ||
- name: Checkout ${{ github.repository }} | ||
uses: actions/checkout@v2 | ||
with: | ||
path: ${{ github.repository }} | ||
repository: ${{ github.repository }} | ||
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} | ||
- uses: benjlevesque/[email protected] | ||
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: | | ||
echo "Update application version to latest version from ${{ github.repository }}@master ${{ github.repository }}#${{ github.event.number }}" > /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 | ||
- 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 deployments-k8s | ||
working-directory: networkservicemesh/deployments-k8s | ||
run: | | ||
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 | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "NSMBot" | ||
git commit -s -F /tmp/commit-message | ||
git checkout -b update/${{ github.repository }} | ||
git push -f origin update/${{ github.repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,78 +179,3 @@ jobs: | |
docker image rm "${ORG}/${NAME}:${GITHUB_SHA::8}" | ||
docker push "${ORG}/${NAME}" | ||
docker image rm "${ORG}/${NAME}" | ||
automerge: | ||
name: automerge | ||
runs-on: ubuntu-latest | ||
needs: | ||
- update-deployments-k8s | ||
if: github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request' | ||
steps: | ||
- name: Check out the code | ||
uses: actions/checkout@v2 | ||
- name: Fetch master | ||
run: | | ||
git remote -v | ||
git fetch --depth=1 origin master | ||
- name: NSMBot should update only config files | ||
run: find . -type f ! -name 'go.mod' ! -name 'go.sum' ! -name '*.yaml' ! -name '*.yml' ! -name '*.txt' ! -name '*.md' ! -name '*.conf' -exec git diff --exit-code origin/master -- {} + | ||
- name: Automerge nsmbot PR | ||
uses: ridedott/merge-me-action@master | ||
with: | ||
GITHUB_LOGIN: nsmbot | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
update-deployments-k8s: | ||
name: Update deployments-k8s | ||
runs-on: ubuntu-latest | ||
needs: | ||
- pushImage | ||
if: github.repository != 'networkservicemesh/cmd-template' && github.actor == 'nsmbot' && github.base_ref == 'master' && github.event_name == 'pull_request' | ||
steps: | ||
- name: Checkout ${{ github.repository }} | ||
uses: actions/checkout@v2 | ||
with: | ||
path: ${{ github.repository }} | ||
repository: ${{ github.repository }} | ||
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} | ||
- uses: benjlevesque/[email protected] | ||
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: | | ||
echo "Update application version to latest version from ${{ github.repository }}@master ${{ github.repository }}#${{ github.event.number }}" > /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 | ||
- 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 deployments-k8s | ||
working-directory: networkservicemesh/deployments-k8s | ||
run: | | ||
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 | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "NSMBot" | ||
git commit -s -F /tmp/commit-message | ||
git checkout -b update/${{ github.repository }} | ||
git push -f origin update/${{ github.repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
README.md | ||
README.md | ||
.golangci.yml |