forked from ecamp/ecamp3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ecamp3-logging: add workflow to deploy it with github actions
Use set -a to export the variables in .env directly. We can only use single line env variables as vars and secrets here.
- Loading branch information
Showing
8 changed files
with
93 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Deploy ecamp3-logging | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: 'Choose environment' | ||
type: environment | ||
required: true | ||
|
||
jobs: | ||
deploy-ecamp3-logging: | ||
name: "Deploy ecamp3-logging" | ||
runs-on: ubuntu-latest | ||
environment: ${{ github.event.inputs.environment }} | ||
steps: | ||
- name: Validate environment | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
if (!"${{ github.event.inputs.environment }}".startsWith("ecamp3-logging")) { | ||
throw new Error("Environment must start with 'ecamp3-logging'"); | ||
} | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
||
- name: Dump secrets to .env | ||
run: | | ||
echo '${{ toJSON(secrets) }}' | jq -r 'keys[] as $k | select(.[$k] |contains("\n") | not) | "\($k)=\"\(.[$k])\""' >> .env | ||
working-directory: .ops/ecamp3-logging | ||
|
||
- name: Dump variables to .env | ||
run: | | ||
echo '${{ toJSON(vars) }}' | jq -r 'keys[] as $k | select(.[$k] |contains("\n") | not) | "\($k)=\"\(.[$k])\""' >> .env | ||
working-directory: .ops/ecamp3-logging | ||
|
||
- name: Show .env for debugging | ||
run: echo "$(cat .env | sort)" | ||
working-directory: .ops/ecamp3-logging | ||
|
||
- name: Setup helm | ||
run: | | ||
mkdir ~/.kube && echo '${{ secrets.KUBECONFIG }}' > ~/.kube/config && chmod go-r ~/.kube/config | ||
- name: Add helm repositories | ||
run: | | ||
helm repo add fluent https://fluent.github.io/helm-charts | ||
helm repo update | ||
- name: Diff deployment | ||
run: | | ||
./deploy.sh diff || true | ||
working-directory: .ops/ecamp3-logging | ||
|
||
- name: Show values.out.yaml | ||
run: cat values.out.yaml | ||
working-directory: .ops/ecamp3-logging | ||
|
||
- name: Deploy | ||
run: | | ||
./deploy.sh deploy | ||
working-directory: .ops/ecamp3-logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/charts | ||
.env | ||
/charts | ||
/values.out.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.env | ||
/deploy.sh | ||
/values.out.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
set -e | ||
set -ea | ||
|
||
SCRIPT_DIR=$(realpath "$(dirname "$0")") | ||
cd $SCRIPT_DIR | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <prod|dev>" | ||
echo "(or other environments)" | ||
exit 1 | ||
fi | ||
. $SCRIPT_DIR/.env | ||
|
||
envsubst < $SCRIPT_DIR/values.yaml > $SCRIPT_DIR/values.out.yaml || true | ||
|
||
# to debug: --dry-run --debug | ||
helm dep build | ||
helm upgrade --install ecamp3-logging \ | ||
--namespace=ecamp3-logging \ | ||
--create-namespace \ | ||
$SCRIPT_DIR \ | ||
--values $SCRIPT_DIR/values.yaml \ | ||
--values $SCRIPT_DIR/values-$1.yaml | ||
|
||
if [ $1 = "deploy" ]; then | ||
# to debug: --dry-run --debug | ||
helm upgrade --install ecamp3-logging \ | ||
--namespace ecamp3-logging \ | ||
--create-namespace \ | ||
$SCRIPT_DIR \ | ||
--values $SCRIPT_DIR/values.out.yaml | ||
exit 0 | ||
fi | ||
|
||
if [ $1 = "diff" ]; then | ||
helm template \ | ||
--namespace ecamp3-logging --no-hooks --skip-tests ecamp3-logging \ | ||
$SCRIPT_DIR \ | ||
--values $SCRIPT_DIR/values.out.yaml | kubectl diff --namespace ecamp3-logging -f - | ||
exit 0 | ||
fi |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters