-
Notifications
You must be signed in to change notification settings - Fork 104
112 lines (98 loc) · 3.56 KB
/
Release-warriors-battle.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
name: Release - Deploy New Tamagotchi/Warriors Battle
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ENVIRONMENT: prod
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
KUBECTL_VERSION: "v1.22.17"
KUBE_NAMESPACE: gear-dapps
KUBE_DEPLOYMENT_PREFIX: tamagotchi-battle-new
REGISTRY: ghcr.io/${{ github.repository }}
jobs:
prepair:
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.image.outputs.image_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get branch
id: branch
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Get short SHA
id: sha
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_ENV
- name: Set IMAGE_NAME
id: image
run: |
image_name=${{ env.REGISTRY }}-${{ env.KUBE_DEPLOYMENT_PREFIX }}:${{ env.branch_name }}-${{ env.sha_short }}
echo "image_name=$image_name" >> $GITHUB_OUTPUT
build-and-push-image:
needs: [prepair]
runs-on: ubuntu-latest
environment: prod
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the github container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: frontend/apps/web3-warriors-battle/Dockerfile
push: true
tags: ${{ needs.prepair.outputs.image_name }}
build-args: |
VITE_DNS_API_URL=${{ secrets.VITE_DNS_API_URL_TESTNET }}
VITE_NODE_ADDRESS=${{ secrets.VITE_NODE_ADDRESS_TESTNET }}
VITE_DNS_NAME=${{ secrets.VITE_DNS_NAME_BATTLE_NEW }}
VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN }}
VITE_GTM_ID=${{ secrets.VITE_GTM_ID_BATTLE_NEW }}
deploy-to-k8s:
needs: [prepair, build-and-push-image]
runs-on: ubuntu-latest
environment: prod
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Update deployment image
uses: kodermax/kubectl-aws-eks@main
with:
args: |
set image deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }}=${{ needs.prepair.outputs.image_name }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Restart deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout restart deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Check deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout status deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
--timeout=240s \
-n ${{ env.KUBE_NAMESPACE }}