Skip to content

Commit

Permalink
update prod flow
Browse files Browse the repository at this point in the history
  • Loading branch information
rf-opssupport committed Jul 29, 2024
1 parent d061e82 commit 3814344
Showing 1 changed file with 15 additions and 32 deletions.
47 changes: 15 additions & 32 deletions .github/workflows/prod-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler
<<<<<<< HEAD
=======
#
>>>>>>> main


name: PROD-CI-CD

Expand All @@ -17,8 +14,10 @@ on:
push:
branches: [main]

permissions:
contents: write

jobs:
<<<<<<< HEAD

Publish-Release:
runs-on: ubuntu-latest
Expand All @@ -29,19 +28,14 @@ jobs:
with:
publish : true
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}

GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
outputs:
release_id: ${{ steps.new_publish.outputs.id }}
release_name: ${{ steps.new_publish.outputs.tag_name }}





Deploy-ECS:
needs: Publish-Release
=======
Deploy-ECS:
>>>>>>> main
environment: prod
runs-on: ubuntu-latest

Expand All @@ -63,24 +57,28 @@ jobs:
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | sed "s/\\//-/g")"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=repo_name::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')"
- name: Another step
run: |
echo "Branch: ${{ steps.vars.outputs.branch }}"
echo "Sha: ${{ steps.vars.outputs.sha_short }}"
echo "Repo: ${{ steps.vars.outputs.repo_name }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Amazon ECR
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
Expand All @@ -89,11 +87,7 @@ jobs:
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
<<<<<<< HEAD
tags: public.ecr.aws/i9y2d4u3/careplan:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }}
=======
tags: public.ecr.aws/i9y2d4u3/careplan-service-prod:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }}
>>>>>>> main
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

Expand All @@ -104,17 +98,14 @@ jobs:
run: |
aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} \
--query taskDefinition > task-definition.json
- name: 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: default
<<<<<<< HEAD
image: public.ecr.aws/i9y2d4u3/careplan:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }}
=======
image: public.ecr.aws/i9y2d4u3/careplan-service-prod:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }}
>>>>>>> main

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
Expand All @@ -127,23 +118,15 @@ jobs:
shell: bash
run: |
echo "::set-output name=task_definition_arn::$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')"
- name: Task Defintion ARN
run: |
echo "Task Defintion: ${{ steps.taskdefintionvar.outputs.task_definition_arn }}"
- name: Deploy Amazon ECS task definition using Duplo API
uses: fjogeleit/http-request-action@master
with:
url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService'
method: 'POST'
data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}'
bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }}
<<<<<<< HEAD
=======

- name: New Release Publish
uses: release-drafter/release-drafter@v5
with:
publish : true
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
>>>>>>> main
bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }}

0 comments on commit 3814344

Please sign in to comment.