-
Notifications
You must be signed in to change notification settings - Fork 25
57 lines (50 loc) · 1.67 KB
/
docker-build-image.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
56
57
name: HDX/CKAN create image
on:
push:
branches:
- dev
- prod
- hdx-*
tags: [ '*' ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v3
- name: Repo Info
id: repo_info
run: |
export REPO_NAME="${GITHUB_REPOSITORY#*/}"
echo ::set-output name=REPO_NAME::${REPO_NAME}
- name: Tag Info
id: tag_info
run: |
export IMAGE_TAG="${GITHUB_REF#refs/*/}"
export IMAGE_TAG=${IMAGE_TAG//[^[:alnum:].-]/-}
echo ::set-output name=IMAGE_TAG::$([[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]] && echo "$GITHUB_SHA" || echo "$IMAGE_TAG")
- name: Show image tag
run: |
echo "Image tag is ${{ steps.tag_info.outputs.IMAGE_TAG }}"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
password: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
- name: Build, tag, and push image to Amazon ECR
uses: docker/build-push-action@v3
with:
push: true
file: ./Dockerfile
tags: public.ecr.aws/unocha/${{ steps.repo_info.outputs.REPO_NAME }}:${{ steps.tag_info.outputs.IMAGE_TAG }}