-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (47 loc) · 1.58 KB
/
image-push.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
name: Push image to ECR
on:
workflow_call:
inputs:
image-tag:
type: string
description: 'The tag of the image to push to ECR'
required: true
image-path:
type: string
description: 'The path to the Dockerfile'
required: true
repository:
type: string
description: 'The ECR repository'
required: true
registry:
type: string
description: 'The ECR registry'
required: true
outputs:
image:
value: ${{ jobs.publish.outputs.image }}
jobs:
publish:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.build-image.outputs.image }}
steps:
- uses: actions/checkout@v3
- name: Login to Amazon ECR
id: login-ecr
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Run unit tests
id: run-tests
run: |
docker build --target test -t '${{ inputs.registry }}/${{ inputs.repository }}:${{ inputs.image-tag }}' '${{ inputs.image-path }}'
- name: Build, tag and push image
id: build-image
run: |
docker build -t '${{ inputs.registry }}/${{ inputs.repository }}:${{ inputs.image-tag }}' '${{ inputs.image-path }}'
docker push '${{ inputs.registry }}/${{ inputs.repository }}:${{ inputs.image-tag }}'
echo 'image=${{ inputs.registry }}/${{ inputs.repository }}:${{ inputs.image-tag }}' >> $GITHUB_OUTPUT