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.
ops-dashboard: add workflow to deploy it with github actions
Use set -a to export the variables in .env directly.
- Loading branch information
Showing
7 changed files
with
144 additions
and
62 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,60 @@ | ||
name: Deploy ops-dashboard | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: 'Choose environment' | ||
type: environment | ||
required: true | ||
|
||
jobs: | ||
deploy-ops-dashboard: | ||
name: "Deploy ops-dashboard" | ||
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("ops-dashboard")) { | ||
throw new Error("Environment must start with 'ops-dashboard'"); | ||
} | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
||
- name: Dump secrets to .env | ||
run: | | ||
echo '${{ toJSON(secrets) }}' | jq -r 'keys[] as $k | "\($k)=\(.[$k])"' >> .env | ||
working-directory: .ops/ops-dashboard | ||
|
||
- name: Dump variables to .env | ||
run: | | ||
echo '${{ toJSON(vars) }}' | jq -r 'keys[] as $k | "\($k)=\(.[$k])"' >> .env | ||
working-directory: .ops/ops-dashboard | ||
|
||
- name: Show .env for debugging | ||
run: echo "$(cat .env | sort)" | ||
working-directory: .ops/ops-dashboard | ||
|
||
- name: Setup helm | ||
run: | | ||
mkdir ~/.kube && echo '${{ secrets.KUBECONFIG }}' > ~/.kube/config && chmod go-r ~/.kube/config | ||
- name: Add helm repositories | ||
run: | | ||
helm repo add oauth2-proxy https://oauth2-proxy.github.io/manifests | ||
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ | ||
helm repo update | ||
- name: Diff deployment | ||
run: | | ||
./deploy.sh diff | ||
working-directory: .ops/ops-dashboard | ||
|
||
- name: Deploy | ||
run: | | ||
./deploy.sh deploy | ||
working-directory: .ops/ops-dashboard |
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,13 @@ | ||
COOKIE_SECRET= | ||
|
||
GRAFANA_HOST= | ||
GRAFANA_OAUTH_CLIENT_ID= | ||
GRAFANA_OAUTH_CLIENT_SECRET= | ||
|
||
KUBERNETES_DASHBOARD_PROXY_HOST= | ||
KUBERNETES_DASHBOARD_PROXY_OAUTH_CLIENT_ID= | ||
KUBERNETES_DASHBOARD_PROXY_OAUTH_CLIENT_SECRET= | ||
|
||
LOGGING_PROXY_HOST= | ||
LOGGING_PROXY_OAUTH_CLIENT_ID= | ||
LOGGING_PROXY_OAUTH_CLIENT_SECRET= |
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 @@ | ||
/.env | ||
/charts | ||
/values.access.yaml | ||
/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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
set -e | ||
set -ea | ||
|
||
SCRIPT_DIR=$(realpath "$(dirname "$0")") | ||
cd $SCRIPT_DIR | ||
|
||
# to debug: --dry-run --debug | ||
helm dep build && helm upgrade --install ops-dashboard --namespace=ops-dashboard --create-namespace $SCRIPT_DIR --values $SCRIPT_DIR/values.yaml --values $SCRIPT_DIR/values.access.yaml | ||
. $SCRIPT_DIR/.env | ||
|
||
envsubst < $SCRIPT_DIR/values.yaml > $SCRIPT_DIR/values.out.yaml | ||
|
||
helm dep build | ||
|
||
if [ $1 = "deploy" ]; then | ||
# to debug: --dry-run --debug | ||
helm upgrade --install ops-dashboard --namespace=ops-dashboard --create-namespace $SCRIPT_DIR --values $SCRIPT_DIR/values.out.yaml | ||
exit 1 | ||
fi | ||
|
||
if [ $1 = "diff" ]; then | ||
# to debug: --dry-run --debug | ||
helm template \ | ||
--namespace ops-dashboard --no-hooks --skip-tests ops-dashboard \ | ||
$SCRIPT_DIR \ | ||
--values $SCRIPT_DIR/values.out.yaml | kubectl diff --namespace ops-dashboard -f - | batcat -l diff - | ||
exit 1 | ||
fi |
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