Skip to content

Merge pull request #1692 from scpwiki/WJ-1200-site-user #303

Merge pull request #1692 from scpwiki/WJ-1200-site-user

Merge pull request #1692 from scpwiki/WJ-1200-site-user #303

name: '[backend] Docker push API'
on:
push:
branches:
- develop
paths:
- 'deepwell/**'
- 'install/aws/dev/docker/api/**'
- '.github/workflows/docker-build-push-api.dev.yaml'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DOCKER_PUSH_KEY }}
aws-secret-access-key: ${{ secrets.DOCKER_PUSH_SECRET }}
aws-region: us-east-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
DOCKER_BUILDKIT: 1
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: wikijump-dev/api
IMAGE_TAG: ${{ github.sha }}
run: |
set -ex
docker build -f install/aws/dev/docker/api/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:develop .
docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition wikijump-dev-ec2 --query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: api
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: wikijump-dev-svc
cluster: wikijump-dev
wait-for-service-stability: true