forked from Squidex/squidex
-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (89 loc) · 3.45 KB
/
Copy pathdev-staging.yml
File metadata and controls
106 lines (89 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Deploy to Dev/Staging
on:
workflow_dispatch:
inputs:
choice:
type: choice
description: Select an Environment
options:
- homer-content-v2
tag:
description: The tag of Squidex to pull
jobs:
build_and_deploy:
name: Deploy
runs-on: ubuntu-latest # Using a linux runner
# Setting environment variables
env:
IMAGE_TAG: ${{ github.event.inputs.tag }}
HELM_PATH: ${{ github.workspace }}/k8s
NAMESPACE: ${{ github.event.inputs.choice }}
steps:
- name: set-env-vars
uses: FranzDiebold/github-env-vars-action@v2
# Checks out the current repository
- name: Check out code
uses: actions/checkout@v2
# Helm is required to generate the manifests
- name: Install Helm
run: |
wget https://get.helm.sh/helm-v3.9.1-linux-amd64.tar.gz
tar xvf helm-v3.9.1-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin
echo "Installed helm"
# Install yq - yaml processor
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod a+x /usr/local/bin/yq
yq --version
echo "Installed yq"
- name: Debug Secret Injection
run: echo "${{ secrets.STAGING_KUBECONFIG }}" | wc -l
# Set kubeconfig context for Staging cluster
- name: Staging :- Set Kubeconfig
if: ${{ github.event.inputs.choice != 'devopsTest' }}
uses: azure/k8s-set-context@v2
with:
method: kubeconfig
kubeconfig: ${{ secrets.STAGING_KUBECONFIG }}
# This generates the deployment manifests for specified environment
- name: Generate manifest for '${{ env.APP_ENVIRONMENT }}'
run: |
export DEPLOY_NAME=$(yq e '.name' $HELM_PATH/staging/values.yaml)
export REPLICAS=$(kubectl get deployment $DEPLOY_NAME -n $NAMESPACE -o=jsonpath={.spec.replicas})
[ -z $REPLICAS ] && export REPLICAS=$(yq e '.replicas' $HELM_PATH/values.yaml)
echo "Number of replicas: $REPLICAS"
echo "Namespace: $NAMESPACE"
echo "NAMESPACE=$NAMESPACE" >> $GITHUB_ENV
helm template $HELM_PATH/squidex -f $HELM_PATH/staging/$NAMESPACE.yaml --set imageTag=$IMAGE_TAG --set replicas=$REPLICAS --set version=$NAMESPACE > manifest.yaml
echo "Generated manifest"
# This deploys to staging/test cluster, for the specified env
- name: Deploy to '${{ env.APP_ENVIRONMENT }}'
uses: Azure/k8s-deploy@v4.4
with:
namespace: ${{ env.NAMESPACE }}
kubeconfig: ${{ secrets.STAGING_KUBECONFIG }}
manifests: |
./manifest.yaml
./Dockerfile
# slack-notify-success:
# if: ${{ success() }}
# needs: [build_and_deploy]
# uses: LearnWithHomer/infrastructure-public/.github/workflows/slack-notify-success.yml@main
# with:
# app_env: ${{ github.event.inputs.choice }}
# slack_channel: homer-staging-status
# runner: ubuntu-latest
# secrets:
# slack_bot_token: ${{ secrets.CODESPARK_SLACK_BOT_TOKEN }}
# slack-notify-failure:
# if: ${{ failure() }}
# needs: [build_and_deploy]
# uses: LearnWithHomer/infrastructure-public/.github/workflows/slack-notify-failure.yml@main
# with:
# app_env: ${{ github.event.inputs.choice }}
# slack_channel: homer-staging-status
# runner: ubuntu-latest
# secrets:
# slack_bot_token: ${{ secrets.CODESPARK_SLACK_BOT_TOKEN }}