From 682b8cc0ee4f18396d1d45fc34084c4c7fed8baf Mon Sep 17 00:00:00 2001 From: ringotc Date: Wed, 6 Mar 2024 13:56:03 -0800 Subject: [PATCH] test4release --- .github/workflows/deploy.yml | 31 ++++++++++++++++++------------- .releaserc | 6 +++--- test.sh | 7 ------- 3 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 test.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 12a46b1..4afa9b4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,21 +32,26 @@ jobs: - name: Get channel information id: get-channel run: | - echo "Current branch: ${{ steps.branch-names.outputs.current_branch }}" - branch_name=${{ steps.branch-names.outputs.current_branch }} - - content=$(cat .releaserc) - - channel=$(echo "$content" | jq -r --arg branch "$branch_name" '.branches[] | select(.name | test("^" + $branch + "$")) | .channel') - - echo "::set-output name=channel::$channel" + BRANCH_NAME="${{ steps.branch-names.outputs.current_branch }}" + content=$(<.releaserc) + branches=$(jq -r '.branches | keys[]' <<< "$content") + for branch in $branches; do + branch_name=$(jq -r ".branches[$branch].name" <<< "$content") + if [[ "$BRANCH_NAME" =~ $branch_name ]]; then + channel=$(jq -r ".branches[$branch].channel" <<< "$content") + echo "::set-output name=channel::$channel" + exit 0 + fi + done + echo "No channel found for branch $BRANCH_NAME" + exit 1 shell: bash - - name: Get deploy token id: resolver run: | - case ${{ steps.get-channel.outputs.channel }} in + CHANNEL="${{ steps.get-channel.outputs.channel }}" + case "$CHANNEL" in "rc") echo "::set-output name=DIGITALOCEAN_TOKEN::${{ secrets.DIGITALOCEAN_PRODUCTION_TOKEN }}" echo "::set-output name=CLUSTER_NAME::${{ secrets.PRODUCTION_CLUSTER_NAME }}" @@ -56,7 +61,7 @@ jobs: echo "::set-output name=CLUSTER_NAME::${{ secrets.TEST_CLUSTER_NAME }}" ;; *) - echo "No token found for channel ${{ steps.get-channel.outputs.channel }}" + echo "No token found for channel $CHANNEL" exit 1 ;; esac @@ -69,7 +74,7 @@ jobs: echo "Channel: ${{ steps.get-channel.outputs.channel }}" echo "DIGITALOCEAN_TOKEN: ${{ steps.resolver.outputs.DIGITALOCEAN_TOKEN }}" echo "CLUSTER_NAME: ${{ steps.resolver.outputs.CLUSTER_NAME }}" - + # - name: Run kustomize # run: (cd ./deployment/base && ../../kustomize edit set image greenstand/treetracker-query-api:${{ steps.package-version.outputs.current-version }} ) # working-directory: ${{ env.project-directory }} @@ -84,4 +89,4 @@ jobs: # - name: Update kubernetes resources # run: kustomize build deployment/overlays/prod | kubectl apply -n webmap --wait -f - - # working-directory: ${{ env.project-directory }} + # working-directory: ${{ env.project-directory }} \ No newline at end of file diff --git a/.releaserc b/.releaserc index f6d6ac5..93fec76 100644 --- a/.releaserc +++ b/.releaserc @@ -5,15 +5,15 @@ "channel": "rc" }, { - "name":"alpha/**", + "name":"alpha/*", "channel": "alpha" }, { - "name":"beta/**", + "name":"beta/*", "channel": "beta" }, { - "name":"rc/**", + "name":"rc/*", "channel": "rc" } ], diff --git a/test.sh b/test.sh deleted file mode 100644 index 06d7c67..0000000 --- a/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -branch_name=$(git rev-parse --abbrev-ref HEAD) - -content=$(cat .releaserc) - -channel=$(echo "$content" | jq -r --arg branch "$branch_name" '.branches[] | select(.name | test("^" + $branch + "$")) | .channel') - -echo "::set-output name=channel::$channel" \ No newline at end of file