-
Notifications
You must be signed in to change notification settings - Fork 4
55 lines (47 loc) · 2.01 KB
/
upload-notes.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
name: Build and Push Upload Notes Service image to ECR
on:
push:
branches:
- main
- chore/build-push
paths:
- 'backend/complex/upload-notes/**'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image to ECR
uses: docker/build-push-action@v2
with:
context: ./backend/complex/upload-notes/
file: ./backend/complex/upload-notes/UploadNotes.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:upload-notes-${{ github.sha }}
platforms: linux/arm64
- name: Clone deployment repository
uses: actions/checkout@v3
with:
repository: ${{ secrets.DEPLOYMENT_REPO }}
token: ${{ secrets.DEPLOYMENT_REPO_TOKEN }}
path: 'deployment-repo'
- name: Update Kubernetes deployment image
run: |
cd deployment-repo
sed -i 's|image: .*|image: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:upload-notes-${{ github.sha }}|' ./kubernetes/complex/upload-notes/upload-notes-deployment.yaml
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Update image tag to ${{ github.sha }}"
git push