-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from LD4P/github_actions
add github actions for int, stg, and public
- Loading branch information
Showing
3 changed files
with
107 additions
and
23 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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 main branch to staging image at Amazon ECR as ld4p/qa_authority_lookup-stg | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
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-stg" >> $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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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: | ||
release: | ||
types: [ published ] | ||
|
||
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-stg" >> $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 |