forked from apecloud/apecloud-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (119 loc) · 4 KB
/
deploy-aws-eks.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: DEPLOY-AWS-EKS
on:
workflow_call:
inputs:
MAKE_OPS:
description: "The ops name of makefile"
type: string
required: false
default: ''
MAKE_OPS_PRE:
description: "The pre ops name of makefile"
type: string
required: false
default: ''
CLUSTER_NAME:
description: "The cluster name of aws eks"
type: string
required: false
default: ''
REGION:
description: "The regin of aws eks"
type: string
required: false
default: ''
VERSION:
description: "The tag name of image"
type: string
required: false
default: ''
GO_VERSION:
description: "Install the specify version of GO"
type: string
required: false
default: ''
GIT_CONFIG:
description: "InsteadOf git config global url (default: false)"
type: boolean
required: false
default: false
APECD_REF:
description: "The branch name of apecloud-cd (default: main)"
type: string
required: false
default: 'main'
KUBECTL_VERSION:
description: "Install the specify version of kubectl (default: latest)"
type: string
required: false
default: 'v1.28.3'
REMOVE_PREFIX:
description: "Enable remove prefix v (default: true)"
type: boolean
required: false
default: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_USER: ${{ secrets.PERSONAL_ACCESS_USER }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
CONTROLLER_MANAGER_CFG: ${{ secrets.CONTROLLER_MANAGER_CFG }}
OPENCONSOLE_CFG: ${{ secrets.OPENCONSOLE_CFG }}
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_REGISTRY_USER }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
CLOUD_VALUES: ${{ secrets.CLOUD_VALUES }}
RELEASE_VERSION: ${{ inputs.VERSION }}
jobs:
deploy-aws-eks:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
outputs:
tag-name: ${{ steps.get_tag_name.outputs.TAG-NAME }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Go specify version
if: inputs.GO_VERSION
uses: actions/setup-go@v3
with:
go-version: ${{ inputs.GO_VERSION }}
- uses: azure/setup-kubectl@v3
with:
version: "${{ inputs.KUBECTL_VERSION }}"
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- name: git config
if: inputs.GIT_CONFIG
run: |
git config --global url."https://${{ env.GITHUB_USER }}:${{ env.GITHUB_TOKEN }}@github.com".insteadof "https://github.com"
- name: remove v prefix
id: get_tag_name
shell: bash
run: |
tag_name="${{ inputs.VERSION }}"
if [[ "$tag_name" == "v"* && "${{ inputs.REMOVE_PREFIX }}" == "true" ]]; then
tag_name="${tag_name/v/}"
fi
echo TAG-NAME=$tag_name >> $GITHUB_OUTPUT
- uses: aws-actions/configure-aws-credentials@v4
if: ${{ env.AWS_ACCESS_KEY_ID != '' && env.AWS_SECRET_ACCESS_KEY != '' && inputs.REGION != '' }}
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ inputs.REGION }}
- name: make pre
if: inputs.MAKE_OPS_PRE
run: |
make ${{ inputs.MAKE_OPS_PRE }}
- if: ${{ inputs.CLUSTER_NAME != '' && inputs.REGION != '' }}
name: deploy to aws eks
run: |
aws eks update-kubeconfig --region ${{ inputs.REGION }} --name ${{ inputs.CLUSTER_NAME }}
cmd="make ${{ inputs.MAKE_OPS }} "
if [[ ! -z "${{ inputs.VERSION }}" ]]; then
cmd=$cmd"VERSION=${{ steps.get_tag_name.outputs.TAG-NAME }} "
fi
eval "$cmd"