-
Notifications
You must be signed in to change notification settings - Fork 3
55 lines (49 loc) · 1.91 KB
/
aws-push-release-to-public.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
# Description: Builds and pushes the Docker image created by Dockerfile to AWS ECR.
#
# ------------------------
# Outside Configurations
# ------------------------
# Set GitHub Repository Secrets in GitHub application repo (the one defining the image, e.g. ld4p/qa_server_container).
# In GitHub repository click: Settings -> Secrets -> New repository secret -> add the following secrets
# * Name: AWS_ACCESS_KEY_ID
# Value: _copy access key from AWS automation user_
# * Name: AWS_SECRET_ACCESS_KEY
# Value: _copy secret access key from AWS automation user_
name: Push image of release tag to public image at Amazon ECR as ld4p/qa_authority_lookup
on:
workflow_dispatch: # allow for manually running through Actions tab
release:
types: [ published ]
jobs:
build:
name: Build image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set variables
run: |
VER=$(cat VERSION)
AREA=public.ecr.aws
REGISTRY=u8a1v5x2
REPOSITORY=ld4p/qa_authority_lookup
echo "VERSION=$VER" >> $GITHUB_ENV
echo "ECR_AREA=$AREA" >> $GITHUB_ENV
echo "REGISTRY_NAME=$REGISTRY" >> $GITHUB_ENV
echo "REPOSITORY_NAME=$REPOSITORY" >> $GITHUB_ENV
echo "FULL_PATH=$AREA/$REGISTRY/$REPOSITORY" >> $GITHUB_ENV
- name: Login to Public ECR
uses: docker/login-action@v1
with:
registry: ${{ env.ECR_AREA }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_FULL_PATH: ${{ env.FULL_PATH }}
SHA_IMAGE_TAG: ${{ github.sha }}
VERSION_IMAGE_TAG: ${{ env.VERSION }}
run: |
docker build -t $ECR_FULL_PATH:$SHA_IMAGE_TAG -t $ECR_FULL_PATH:$VERSION_IMAGE_TAG -t $ECR_FULL_PATH:latest .
docker push -a $ECR_FULL_PATH