@@ -32,21 +32,26 @@ jobs:
3232 - name : Get channel information
3333 id : get-channel
3434 run : |
35- echo "Current branch: ${{ steps.branch-names.outputs.current_branch }}"
36- branch_name=${{ steps.branch-names.outputs.current_branch }}
37-
38- content=$(cat .releaserc)
39-
40- channel=$(echo "$content" | jq -r --arg branch "$branch_name" '.branches[] | select(.name | test("^" + $branch + "$")) | .channel')
41-
42- echo "::set-output name=channel::$channel"
35+ BRANCH_NAME="${{ steps.branch-names.outputs.current_branch }}"
36+ content=$(<.releaserc)
37+ branches=$(jq -r '.branches | keys[]' <<< "$content")
38+ for branch in $branches; do
39+ branch_name=$(jq -r ".branches[$branch].name" <<< "$content")
40+ if [[ "$BRANCH_NAME" =~ $branch_name ]]; then
41+ channel=$(jq -r ".branches[$branch].channel" <<< "$content")
42+ echo "::set-output name=channel::$channel"
43+ exit 0
44+ fi
45+ done
46+ echo "No channel found for branch $BRANCH_NAME"
47+ exit 1
4348 shell : bash
44-
4549
4650 - name : Get deploy token
4751 id : resolver
4852 run : |
49- case ${{ steps.get-channel.outputs.channel }} in
53+ CHANNEL="${{ steps.get-channel.outputs.channel }}"
54+ case "$CHANNEL" in
5055 "rc")
5156 echo "::set-output name=DIGITALOCEAN_TOKEN::${{ secrets.DIGITALOCEAN_PRODUCTION_TOKEN }}"
5257 echo "::set-output name=CLUSTER_NAME::${{ secrets.PRODUCTION_CLUSTER_NAME }}"
5661 echo "::set-output name=CLUSTER_NAME::${{ secrets.TEST_CLUSTER_NAME }}"
5762 ;;
5863 *)
59- echo "No token found for channel ${{ steps.get-channel.outputs.channel }} "
64+ echo "No token found for channel $CHANNEL "
6065 exit 1
6166 ;;
6267 esac
6974 echo "Channel: ${{ steps.get-channel.outputs.channel }}"
7075 echo "DIGITALOCEAN_TOKEN: ${{ steps.resolver.outputs.DIGITALOCEAN_TOKEN }}"
7176 echo "CLUSTER_NAME: ${{ steps.resolver.outputs.CLUSTER_NAME }}"
72-
77+
7378 # - name: Run kustomize
7479 # run: (cd ./deployment/base && ../../kustomize edit set image greenstand/treetracker-query-api:${{ steps.package-version.outputs.current-version }} )
7580 # working-directory: ${{ env.project-directory }}
8489
8590 # - name: Update kubernetes resources
8691 # run: kustomize build deployment/overlays/prod | kubectl apply -n webmap --wait -f -
87- # working-directory: ${{ env.project-directory }}
92+ # working-directory: ${{ env.project-directory }}
0 commit comments