-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (37 loc) · 1.44 KB
/
ci.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
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
if: github.ref_name == 'develop' || github.ref_name == 'master' || github.ref_type == 'tag'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_PUBLIC_REPO_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_PUBLIC_REPO_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
mask-aws-account-id: 'true'
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Prepare lowercase repository name
run: echo "REPOSITORY=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Prepare unique image tag
run: |
IMAGE_TAG=$GITHUB_REF_NAME
[[ $GITHUB_REF_TYPE == 'branch' ]] && IMAGE_TAG="${IMAGE_TAG}-${GITHUB_SHA:0:7}-$(date +'%s')"
echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_ENV"
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ secrets.ECR_REGISTRY }}
REPOSITORY: ${{ env.REPOSITORY }}
IMAGE_TAG: ${{ env.IMAGE_TAG }}
run: |
docker build \
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG \
-f docker/build/Dockerfile .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG