Skip to content

Merge pull request #313 from AppQuality/develop #2286

Merge pull request #313 from AppQuality/develop

Merge pull request #313 from AppQuality/develop #2286

Workflow file for this run

on:
push:
branches:
- "*"
name: Push to Amazon ECR
jobs:
push-to-ecr:
name: Push Image
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: |
BRANCH=$(echo ${GITHUB_REF#refs/heads/})
if [ "$BRANCH" = "master" ]; then
TAG="latest"
else
TAG="$BRANCH"
fi
echo "##[set-output name=tag;]$TAG"
id: extract_branch
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@aaf69d68aa3fb14c1d5a6be9ac61fe15b48453a2
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: appq-register-page
IMAGE_TAG: ${{ steps.extract_branch.outputs.tag }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build \
--build-arg NPM_TOKEN=${{ secrets.NPM_TOKEN }} \
--build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"