-
Notifications
You must be signed in to change notification settings - Fork 65
80 lines (72 loc) · 2.63 KB
/
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
name: Deploy
on:
push:
branches:
- main
- dev
workflow_dispatch:
inputs:
build:
description: "Build trigger"
required: true
default: "enable"
type: choice
options:
- enable
- disable
environment:
description: "Environment"
required: true
default: "prod"
type: choice
options:
- prod
- stg
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
env:
DATA: ${{ github.event.inputs.build || 'enable' }}
DATA_ENV: ${{ github.event.inputs.environment || 'prod' }}
permissions:
id-token: write
contents: read
steps:
- name: Manipulate Environment
id: manipulate
run: |
if [ "${{ github.event_name }}" = "push" ] && [ "$GITHUB_REF_NAME" = "main" ]; then
echo "env=prod" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "push" ] && [ "$GITHUB_REF_NAME" = "dev" ]; then
echo "env=stg" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "env=${{ env.DATA_ENV }}" >> $GITHUB_OUTPUT
else
echo "Operation not permitted"
exit 1
fi
- name: Check production branch
run: |
if [ "${{ steps.manipulate.outputs.env }}" = "prod" ] && [ "$GITHUB_REF_NAME" != "main" ]; then
echo "Operation not permitted"
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::490752553772:role/bandada-ecs-deploy-slc
role-duration-seconds: 2700
aws-region: eu-central-1
- name: Build and Push images to ECR
run: |
.github/scripts/build.sh ${{ env.DATA }} ${{ steps.manipulate.outputs.env }}
- name: Create Deployment
run: |
.github/scripts/deploy.sh ${{ steps.manipulate.outputs.env }}