name: Reusable workflow for build / push / deploy
on:
workflow_call:
inputs:
SERVICE_NAME:
type: string
required: true
DIR_NAME:
type: string
required: true
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
SLACK_BOT_TOKEN:
required: true
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: server-${{ inputs.SERVICE_NAME }}
ECR_REGISTRY: xxxxx
IMAGE_TAG: ${{ github.sha }}
SERVICE_NAME: ${{ inputs.SERVICE_NAME }}
DIR_NAME: ${{ inputs.DIR_NAME }}
jobs:
build_push_deploy:
name: BuildPushDeploy
runs-on: ubuntu-latest
timeout-minutes: 12
steps:
- name: print env
run: env
- name: set environment (staging)
if: github.ref_name == 'staging'
run: |
echo "branch is staging"
echo "ECS_SERVICE= ${{ env.SERVICE_NAME }}-server" >> $GITHUB_ENV
echo "ECS_CLUSTER= staging-cluster" >> $GITHUB_ENV
echo "ECS_TASK_DEFINITION=fffff.${{ env.DIR_NAME }}/${{ env.SERVICE_NAME }}-server-staging-task-definition.json" >> $GITHUB_ENV
echo "CONTAINER_NAME= ${{ env.SERVICE_NAME }}-server" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- 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: ${{ env.AWS_REGION }}
- 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
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -f ffff.${{ env.DIR_NAME }}/Dockerfile -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"
- 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: ${{ 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: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
- name: Notify slack
if: always()
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel_id: cccccccc
status: ${{ job.status }}
color: ${{ job.status == 'success' && 'good' || 'danger' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
STATUS: ${{ job.status }}
on:
push:
branches: [master,staging,sandbox]
paths:
- 'fff.ooo/**'
- '.github/workflows/ooo_build_push_ecr_deploy_ecs.yml'
- '.github/workflows/workflow_build_push_ecr_deploy_ecs.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: xxxxx
ECR_REGISTRY: xxxxxxx
IMAGE_TAG: ${{ github.sha }}
name: Orders> build Docker image, push to ECR, deploy to ECS
jobs:
build_push_deploy:
uses: ./.github/workflows/workflow_build_push_ecr_deploy_ecs.yml
with:
DIR_NAME: "ooooo"
SERVICE_NAME: "oooo"
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Сервис мониторит 2 IP адреса и имеет актуальное значение состояний провов.
- При поступлении запроса от ЯМ, отправляем уже на любой доступный или по приоритету.
swap не восстанавливается после сборки, процесс то закончился, а это вроде часть оперативной памяти ...