Skip to content

Commit

Permalink
Set the values file by target environment
Browse files Browse the repository at this point in the history
If the branch name is:
 - test
 - starts with test-
 - ends in -test
 - has *-test/*
 - has */test-*
then test

If the branch name is:
 - main
then prod

Otherwise:
stage
  • Loading branch information
jhriv committed Jan 12, 2024
1 parent d1df0ab commit 7f75c64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/build-dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set the K8S Environment
run: echo "K8S_DEPLOY_ENVIRONMENT=$($GITHUB_WORKSPACE/.github/workflows/get-k8s-environment.sh)" >> "$GITHUB_ENV"

- name: Read chart yaml to get version for docker tag
id: image-tag
uses: KJ002/[email protected]
with:
file: 'charts/prod-oralhistory-values.yaml'
file: 'charts/${{ env.K8S_DEPLOY_ENVIRONMENT }}-oralhistory-values.yaml'
key-path: '["image", "tag"]'

- name: Report image tag
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/get-k8s-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

case "$GITHUB_REF" in
test | test-* | */test | */test-* | *-test/* | *-test)
echo test ;;
main)
echo prod ;;
*)
echo stage ;;
esac

0 comments on commit 7f75c64

Please sign in to comment.