Browse Source

start use pr number instead of branch name for custom deployments (#2179)

Co-authored-by: Azat Safin <azsafin@provectus.com>
azatsafin 3 years ago
parent
commit
d0e1e2bf6a
2 changed files with 3 additions and 11 deletions
  1. 1 5
      .github/workflows/branch-deploy.yml
  2. 2 6
      .github/workflows/branch-remove.yml

+ 1 - 5
.github/workflows/branch-deploy.yml

@@ -13,11 +13,7 @@ jobs:
       - name: get branch name
         id: extract_branch
         run: |
-          hub pr checkout ${{ github.event.pull_request.number }}
-          branch_name=$(hub branch | grep "*" | sed -e 's/^\*//')
-          echo $branch_name
-          echo ::set-output name=branch::${branch_name}
-          tag=$(echo $branch_name |  sed 's/\//-/g' | sed 's/\./-/g' | sed 's/\_/-/g' |  sed -e 's/\(.*\)/\L\1/' | cut -c1-32 | sed -E 's/(^[^a-z0-9])*([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)([^a-z0-9]*)/\2/')
+          tag='pr${{ github.event.pull_request.number }}'
           echo ::set-output name=tag::${tag}
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 2 - 6
.github/workflows/branch-remove.yml

@@ -12,11 +12,7 @@ jobs:
       - name: get branch name
         id: extract_branch
         run: |
-          hub pr checkout ${{ github.event.pull_request.number }}
-          branch_name=$(hub branch | grep "*" | sed -e 's/^\*//')
-          echo $branch_name
-          echo ::set-output name=branch::${branch_name}
-          tag=$(echo $branch_name |  sed 's/\//-/g' | sed 's/\./-/g' | sed 's/\_/-/g' |  cut -c1-32)
+          tag='pr${{ github.event.pull_request.number }}'
           echo ::set-output name=tag::${tag}
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -27,7 +23,7 @@ jobs:
         run: |
           cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
           echo "Branch:${{ steps.extract_branch.outputs.tag }}"
-          ./delete-env.sh ${{ steps.extract_branch.outputs.tag }}
+          ./delete-env.sh ${{ steps.extract_branch.outputs.tag }} || true
           git config --global user.email "kafka-ui-infra@provectus.com"
           git config --global user.name "kafka-ui-infra"
           git add ../kafka-ui-from-branch/