Push image of dev branch to integration image at Amazon ECR as ld4p/qa_authority_lookup-int #52
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 dev branch to integration image at Amazon ECR as ld4p/qa_authority_lookup-int | |
on: | |
workflow_dispatch: # allow for manually running through Actions tab | |
push: | |
branches: [ dev ] | |
jobs: | |
build: | |
name: Build image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set variables | |
run: | | |
VER=$(cat VERSION) | |
echo "VERSION=$VER" >> $GITHUB_ENV | |
echo "REPOSITORY_NAME=ld4p/qa_authority_lookup-int" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ env.REPOSITORY_NAME }} | |
SHA_IMAGE_TAG: ${{ github.sha }} | |
VERSION_IMAGE_TAG: ${{ env.VERSION }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$SHA_IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$VERSION_IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . | |
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY |