-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (43 loc) · 1.48 KB
/
Copy pathci.yaml
File metadata and controls
50 lines (43 loc) · 1.48 KB
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
name: Build and Push to ECR
on:
push:
branches: [main]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-north-1
- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, push image
env:
ECR_REGISTRY: 500888951988.dkr.ecr.eu-north-1.amazonaws.com
ECR_REPOSITORY: devshelf-app
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Update k8s deployment image
env:
ECR_REGISTRY: 500888951988.dkr.ecr.eu-north-1.amazonaws.com
ECR_REPOSITORY: devshelf-app
IMAGE_TAG: ${{ github.sha }}
run: |
sed -i "s|image:.*|image: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g" k8s/deployment.yaml
git config user.name "github-actions"
git config user.email "actions@github.com"
git add k8s/deployment.yaml
git commit -m "ci: update image to $IMAGE_TAG"
git push