Push image of release tag to public image at Amazon ECR as ld4p/qa_authority_lookup #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |