-
Notifications
You must be signed in to change notification settings - Fork 48
52 lines (44 loc) · 1.34 KB
/
aws_dev.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
name: AWS Dev Deployment
on:
push:
branches:
- develop
- test
permissions:
id-token: write
contents: read
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set IMAGE_TAG
run: |
if [[ "${{ github.ref_name }}" == "test" ]]; then
echo "IMAGE_TAG=test" >> $GITHUB_ENV
else
echo "IMAGE_TAG=dev" >> $GITHUB_ENV
fi
- name: AWS config
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_DEV_ROLE }}
role-session-name: GithubNGAGeointSession
aws-region: ${{ secrets.AWS_DEV_REGION }}
- name: AWS ECR Login
id: ecr-login
uses: aws-actions/amazon-ecr-login@v2
- name: Build Docker image and push
env:
REGISTRY: ${{ steps.ecr-login.outputs.registry }}
REPOSITORY: "/mage/server"
IMAGE_TAG: ${{ env.IMAGE_TAG }}
run: |
docker build -t $REGISTRY$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY$REPOSITORY:$IMAGE_TAG
- name: ReDeploy ECS Service
env:
SERVICE: "mage${{ env.IMAGE_TAG }}"
run: |
aws ecs update-service --cluster magedev --service $SERVICE --force-new-deployment