-
Notifications
You must be signed in to change notification settings - Fork 7
71 lines (67 loc) · 2.71 KB
/
fishcake-deploy.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
name: Fishcake Image Build And Deploy
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: environment to choice
options:
- testnet
env:
AWS_REGION : "ap-southeast-1"
app: fishcake
permissions:
id-token: write
contents: read
run-name: Build Image For Repo
jobs:
build:
runs-on: ubuntu-latest
outputs:
commit_sha: ${{ steps.get-commit-sha.outputs.commit_sha }}
ecr_registry: ${{ steps.login-ecr.outputs.registry }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
repository: "FishcakeLab/fishcake-service"
- name: Get Commit Sha
id: get-commit-sha
run: |
echo "::set-output name=commit_sha::$(git rev-parse --short=7 HEAD)"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::942583694543:role/github_assume_role
aws-region: ${{ env.AWS_REGION }}
role-session-name: samplerolesession
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build Docker Image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPO: ${{ env.app }}
#REF: ${{ github.event.inputs.ref }}
COMMIT_SHA: ${{ steps.get-commit-sha.outputs.commit_sha }}
run: |
aws s3 cp s3://eniac-x-labs-config-center/${{ env.app }}/${{ github.event.inputs.environment }}/config.yaml config.yaml
IMAGE_URL1=${ECR_REGISTRY}/${REPO}:${COMMIT_SHA}
export NODE_OPTIONS="--max_old_space_size=9000"
docker build --pull -t ${IMAGE_URL1} .
docker push ${IMAGE_URL1}
- name: deploy app
run: |
aws eks update-kubeconfig --name savour-layer3-eks
# echo 'KUBE_CONFIG_DATA<<EOF' >> $GITHUB_ENV
# echo $(cat /home/runner/.kube/config | base64) >> $GITHUB_ENV
# echo 'EOF' >> $GITHUB_ENV
HELM_OPTS="${HELM_OPTS} --set image.repository=${{ steps.login-ecr.outputs.registry }}/${{ env.app }}"
HELM_OPTS="${HELM_OPTS} --set image.tag=${{ steps.get-commit-sha.outputs.commit_sha }}"
if [ ${{github.event.inputs.environment }} == "testnet" ]; then
helm template ${{ env.app }} -f values.yaml charts -n testnet-layer3 ${HELM_OPTS}
helm upgrade --install ${{ env.app }} -f values.yaml charts -n testnet-layer3 ${HELM_OPTS}
else
helm template ${{ env.app }} -f values.yaml charts -n mainnet ${HELM_OPTS}
helm upgrade --install ${{ env.app }} -f values.yaml charts -n mainnet ${HELM_OPTS}
fi