-
Notifications
You must be signed in to change notification settings - Fork 5
67 lines (55 loc) · 1.87 KB
/
publish-docker-image.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Publish Docker image
on:
push:
tags:
- '*'
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
publish-docker-images:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Checkout and pull branch
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $LATEST_TAG
- name: Setup buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERNAME }}
password: ${{ secrets.DOCKERTOKEN }}
- name: Docker meta for core
id: meta_core
uses: docker/metadata-action@v3
with:
images: codelit/medialit
- name: Build and push API
id: docker_build_api
uses: docker/build-push-action@v2
with:
context: .
file: ./apps/api/Dockerfile
push: true
tags: ${{ steps.meta_core.outputs.tags }}
- name: Image digest
run: echo ${{ steps.docker_build_api.outputs.digest }}
- name: Setup AWS ECR Details
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_ECR_ACCESS_SECRET }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker images to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.AWS_ECR_REPO }}
IMAGE_TAG: latest
run: |
docker build -f apps/web/Dockerfile -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG