-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
148 lines (135 loc) · 4.84 KB
/
action.yaml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
name: 'Xquare deployment'
author: 'Xquare'
branding:
icon: 'Xquare'
color: 'Purple'
description: 'Tasks to deploy to xquare server'
inputs:
environment:
description: 'Environment classification for servers (prod/stag)'
required: true
base_url:
description: 'Base url of code'
default: '.'
base_path:
description: 'Base url of code'
default: '.'
config_file_path:
description: 'Path of Xquare Config file'
default: '.xquare/config.yaml'
access_key:
description: 'Access-key for authenticate to run action'
required: true
yarn_docker_build:
description: 'Boolean value indicating whether to use the "yarn docker build" command instead of the "docker build" command'
default: false
yarn_workspace:
description: 'Workspace name to build docker image'
required: false
buildargs:
description: 'Use buildargs when you want to pass a list of environment variables to docker as build-args'
required: false
build_path:
description: 'build_path when your project is configured multi-module'
default: '.'
required: false
language:
description: 'Language of code'
default: 'null'
required: false
critical_service:
description: 'Deploy ONDEMAND boolean value'
default: false
required: false
private_service:
description: 'Used when exposure to the outside is not possible.'
default: false
required: false
runs:
using: 'composite'
steps:
- name: Install yq
uses: mikefarah/yq@v4
- name: Read config values
id: config-value
uses: team-xquare/xquare-deployment-action/actions/read-config@master
with:
config_file_path: ${{ inputs.config_file_path }}
environment: ${{ inputs.environment }}
- name: Authenticate and get role-arn
id: get-role-arn
uses: team-xquare/xquare-deployment-action/actions/authenticate-and-get-arn@master
with:
access_key: ${{ inputs.access_key }}
project_name: ${{ env.name }}
project_type: ${{ env.type }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.xquare_role_arn }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Get ECR Repository name
id: repository
shell: bash
run: echo "repository_name=${{ env.name }}-${{ env.type }}-${{ inputs.environment }}" >> $GITHUB_OUTPUT
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v1
with:
secret-ids:
xquare/action
parse-json-secrets: true
- name: Create ecr if not exists
uses: team-xquare/xquare-deployment-action/actions/create-ecr@master
with:
repository_name: ${{ steps.repository.outputs.repository_name }}
service_name: ${{ env.name }}
service_type: ${{ env.type }}
environment: ${{ inputs.environment }}
github_token: ${{ env.XQUARE_ACTION_GHP_TOKEN }}
- name: Create domain if not exists
if: ${{ env.domain }}
uses: team-xquare/xquare-deployment-action/actions/create-domain@master
with:
domain: ${{ env.domain }}
github_token: ${{ env.XQUARE_ACTION_GHP_TOKEN }}
- name: Get base path
shell: bash
run: |
if [ "${{ inputs.base_url }}" = "." ] && [ "${{ inputs.base_path }}" != "." ]; then
echo "base_path=${{ inputs.base_path }}" >> $GITHUB_ENV
else
echo "base_path=${{ inputs.base_url }}" >> $GITHUB_ENV
fi
- name: Docker push
id: docker
uses: team-xquare/xquare-deployment-action/actions/docker-push@master
with:
registry_name: ${{ steps.ecr.outputs.registry }}
repository_name: ${{ steps.repository.outputs.repository_name }}
environment: ${{ inputs.environment }}
base_url: ${{ inputs.base_url }}
yarn_docker_build: ${{ inputs.yarn_docker_build }}
yarn_workspace: ${{ inputs.yarn_workspace }}
buildargs: ${{ inputs.buildargs }}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ env.XQUARE_ACTION_GHP_TOKEN }}
repository: team-xquare/xquare-gitops-repo
event-type: update_config
client-payload: |
{
"ref" : "${{ github.ref }}",
"image_tag" : "${{ env.version_tag }}",
"service_name" : "${{ env.name }}",
"service_prefix" : "${{ env.prefix }}",
"service_domain" : "${{ env.domain }}",
"service_type" : "${{ env.type }}",
"service_port" : "${{ env.port }}",
"environment" : "${{ inputs.environment }}",
"critical_service" : "${{ inputs.critical_service }}",
"private_service" : "${{ inputs.private_service }}"
}