Skip to content

Manually triggered deploy #14

Manually triggered deploy

Manually triggered deploy #14

Workflow file for this run

name: Manually triggered deploy
on:
workflow_dispatch:
inputs:
deploy:
description: 'Deploy to ECS dev'
type: boolean
required: true
default: false
env:
AWS_REGION: eu-north-1
ECR_REGISTRY: 590877988961.dkr.ecr.eu-north-1.amazonaws.com
ECR_REPOSITORY: intercom-manager
ECS_SERVICE: intercom-manager
ECS_CLUSTER: development
ECS_TASK_DEFINITION: aws/ecs/taskdef-dev.json
CONTAINER_NAME: intercom-manager
defaults:
run:
shell: bash
jobs:
build:
name: Build image and register in ECR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Configure AWS ECR credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}
flavor: |
latest=false
tags: type=sha
- name: Build docker image and push to Amazon ECR
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
if: ${{ inputs.deploy }}
name: Deploy to Dev cluster on ECS
needs: ['build']
runs-on: ubuntu-latest
steps:
- name: Configure AWS ECS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ECS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECS_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Checkout source code
uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
- 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: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:sha-${{ steps.short-sha.outputs.sha }}
- 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: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true