From 23445a22015b34cd99731d6be9c6905c4e7278d1 Mon Sep 17 00:00:00 2001 From: Network Service Mesh Bot <60070799+nsmbot@users.noreply.github.com> Date: Mon, 24 Jan 2022 21:00:12 -0600 Subject: [PATCH] Sync files with networkservicemesh/cmd-template --- .github/workflows/ci.yaml | 2 +- .github/workflows/release-deployments.yaml | 99 ++++++++++++++++++++++ .github/workflows/update-deployments.yaml | 24 ++++-- 3 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/release-deployments.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c051598..560e4f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -76,7 +76,7 @@ jobs: - uses: actions/checkout@v2 - name: Restrict dependencies on github.com/networkservicemesh/* env: - ALLOWED_REPOSITORIES: "sdk, api, sdk-vpp, sdk-sriov" + ALLOWED_REPOSITORIES: "sdk, api, sdk-k8s, sdk-vpp, 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 diff --git a/.github/workflows/release-deployments.yaml b/.github/workflows/release-deployments.yaml new file mode 100644 index 0000000..bae5a96 --- /dev/null +++ b/.github/workflows/release-deployments.yaml @@ -0,0 +1,99 @@ +--- +name: Release deployments-k8s repository +on: + push: + branches: + - "release/**" +jobs: + check-branch: + name: Check release branch in deployments-k8s + runs-on: ubuntu-latest + steps: + - name: Get tag + run: | + branch=${{ github.event.ref }} + echo '::set-output name=tag::'${branch#refs/heads/release/} + id: get-tag-step + + - 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: check-release-branch + working-directory: networkservicemesh/deployments-k8s + run: | + echo Starting to check release branch in deployments-k8s repository + branch=release/${{ steps.get-tag-step.outputs.tag }} + echo branch to be checked - ${branch} + + if ! [ -z "$(git ls-remote --heads origin ${branch})" ]; then + echo Branch ${branch} is already presented in deployments-k8s repository + exit 0; + fi + + echo Branch ${branch} is not presented in repository + echo Starting to create ${branch} branch in deployments-k8s repository + + git config --global user.email "nsmbot@networkservicmesh.io" + git config --global user.name "NSMBot" + git checkout -b ${branch} + git push -u origin ${branch} || exit 0; + + update-deployments-k8s: + needs: check-branch + name: Update deployments-k8s + runs-on: ubuntu-latest + if: ${{ github.repository != 'networkservicemesh/cmd-template' }} + steps: + - name: Get tag + run: | + branch=${{ github.event.ref }} + echo '::set-output name=tag::'${branch#refs/heads/release/} + id: get-tag-step + + - name: Checkout ${{ github.repository }} + uses: actions/checkout@v2 + with: + path: ${{ github.repository }} + repository: ${{ github.repository }} + + - name: Create commit message + working-directory: ${{ github.repository }} + run: | + echo "Update docker images to the latest tag ${{ steps.get-tag-step.outputs.tag }}" >> /tmp/commit-message + echo "" >> /tmp/commit-message + echo "Commit Message:" + cat /tmp/commit-message + + - 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: Find and Replace ci/${{ github.repository }} version + uses: jacobtomlinson/gha-find-replace@master + with: + find: "ci/${{ github.event.repository.name }}:.*\n" + replace: "${{ github.event.repository.name }}:${{ steps.get-tag-step.outputs.tag }}\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 + + branch=release/${{ github.repository }}/${{ steps.get-tag-step.outputs.tag }} + git config --global user.email "nsmbot@networkservicmesh.io" + git config --global user.name "NSMBot" + git commit -s -F /tmp/commit-message + git checkout -b ${branch} + git push -f origin ${branch} diff --git a/.github/workflows/update-deployments.yaml b/.github/workflows/update-deployments.yaml index 51aba33..05fe3d4 100644 --- a/.github/workflows/update-deployments.yaml +++ b/.github/workflows/update-deployments.yaml @@ -21,16 +21,12 @@ jobs: path: ${{ github.repository }} repository: ${{ github.repository }} token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - - uses: benjlevesque/short-sha@v1.2 - id: short-sha - with: - length: 7 - - name: Checkout networkservicemesh/deployments-k8s - uses: actions/checkout@v2 + - name: Find merged PR + uses: jwalton/gh-find-current-pr@v1.0.2 + id: findPr with: - path: networkservicemesh/deployments-k8s - repository: networkservicemesh/deployments-k8s - token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} + sha: ${{ github.sha }} + github-token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - name: Create commit message working-directory: ${{ github.repository }} run: | @@ -42,6 +38,16 @@ jobs: echo "$LOG_MSG" >> /tmp/commit-message echo "Commit Message:" cat /tmp/commit-message + - uses: benjlevesque/short-sha@v1.2 + id: short-sha + with: + length: 7 + - 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: Find and Replace version uses: jacobtomlinson/gha-find-replace@master with: