-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
18 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
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,64 @@ | ||
name: Publish K8s | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- "**" | ||
- "!main" | ||
|
||
jobs: | ||
publish-helm: | ||
name: "publish helm" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Troubleshooting | ||
run: | | ||
curl -sSL -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | \ | ||
jq "{ jwt: .value, role: \"$VAULT_ROLE\" }" > ./token.json | ||
echo 'GitHub Actions Token Claims' | ||
cat ./token.json | jq -r '.jwt | split(".") | .[1] | @base64d' | jq | ||
echo 'Vault Login Response' | ||
curl -sSLf -X POST -H "Content-Type: application/json" -H "X-Vault-Namespace: admin" --data @token.json $VAULT_URL/v1/auth/$VAULT_AUTH_PATH/login | ||
# Remove the token file when we're done (if we don't fail) | ||
rm ./token.json | ||
env: | ||
VAULT_URL: https://swisstopo-vault-public-vault-d680830d.382257a9.z1.hashicorp.cloud:8200 | ||
VAULT_AUTH_PATH: jwt | ||
VAULT_ROLE: ${{ secrets.VAULT_ROLE }} | ||
- name: "Load secrets" | ||
id: load-secrets | ||
uses: hashicorp/vault-action@v2 | ||
with: | ||
url: https://swisstopo-vault-public-vault-d680830d.382257a9.z1.hashicorp.cloud:8200 | ||
caCertificate: ${{ secrets.VAULT_CA_CERT }} | ||
method: jwt | ||
role: ${{ secrets.VAULT_ROLE }} | ||
namespace: admin/igi/igi-cloud/swisstopo-ngm | ||
secrets: | | ||
kv/data/dev/k8s kubeconfig | KUBECONFIG; | ||
kv/data/dev/k8s helm_values | HELM_VALUES; | ||
kv/data/dev/k8s helm_secrets | HELM_SECRETS; | ||
- name: "Checkout repository" | ||
uses: actions/checkout@v4 | ||
- name: "Setup kubectl" | ||
uses: azure/setup-kubectl@v4 | ||
- name: "Install helm" | ||
uses: azure/setup-helm@v4 | ||
- name: "Write kubeconfig file" | ||
run: | | ||
echo "${{ env.HELM_VALUES }}" > ./k8s/values.yaml | ||
echo "${{ env.HELM_SECRETS }}" > ./k8s/secrets.yaml | ||
echo "${{ env.KUBECONFIG }}" > kubeconfig | ||
- name: "Deploy helm charts" | ||
env: | ||
KUBECONFIG: kubeconfig | ||
run: | | ||
helm upgrade --install ./k8s --values ./k8s/values.yaml --values ./k8s/secrets.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: api | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
eks.amazonaws.com/role-arn: {{ .Values.service_roles.s3 }} |