-
Notifications
You must be signed in to change notification settings - Fork 45
91 lines (84 loc) · 2.98 KB
/
reusable-deploy.yml
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
name: deploy
on:
workflow_dispatch:
inputs:
env:
description: "Target environment for deployment"
required: true
type: string
version:
description: "Version to be assigned to the built image"
required: true
type: string
cluster_name:
description: "Name of the cluster on which to perform deployment"
default: mangata-dev
required: false
type: string
workflow_call:
inputs:
env:
description: "Target environment for deployment"
required: true
type: string
version:
description: "Version to be assigned to the built image"
required: true
type: string
cluster_name:
description: "Name of the cluster on which to perform deployment"
default: mangata-dev
required: false
type: string
permissions:
contents: read
id-token: write
deployments: write
jobs:
deploy:
runs-on: ubuntu-latest
env:
ENV_REF: ${{ inputs.env == 'fungible' && format('pr-{0}', github.event.number) || inputs.env }}
steps:
- uses: actions/checkout@v3
- uses: jkroepke/[email protected]
- name: Setup helmfile
uses: mamezou-tech/[email protected]
with:
install-kubectl: no
install-helm: no
additional-helm-plugins: https://github.com/jkroepke/helm-secrets --version v4.1.1,https://github.com/aslafy-z/helm-git --version 0.14.0
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ inputs.cluster_name }}
location: europe-west1
- name: Create a GitHub Deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.ENV_REF }}
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- run: |
export ENVIRONMENT=${{ env.ENV_REF }}
export IMAGE_TAG=${{ inputs.version }}
# https://dev.to/derlin/helmfile-difference-between-sync-and-apply-helm-3-28o1
export HELM_DIFF_THREE_WAY_MERGE=true
helmfile apply -e ${{ inputs.env }}
working-directory: devops/helmfiles
- name: Update the GitHub Deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fnode-01-ws-${{ env.ENV_REF }}.mangata.online#/explorer"