Skip to content

Fixing user creation #40

Fixing user creation

Fixing user creation #40

Workflow file for this run

# This workflow will trigger pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# 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
name: PROD-CI-CD
# Controls when the workflow will run
# on:
# # Triggers the workflow on push events but only for the develop branch
# push:
# branches: [main]
jobs:
Publish-Release:
runs-on: ubuntu-latest
steps:
- name: New Release Publish
id: new_publish
uses: release-drafter/release-drafter@v5
with:
publish : true
env:
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
environment: prod
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: ${{ secrets.AWS_REGION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- 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@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Copy env file
run: aws s3 cp s3://${{ secrets.ENV_FILE_BUCKET_PATH }}/.env ./.env
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: public.ecr.aws/i9y2d4u3/rean-admin-portal:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Download task definition
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
image: public.ecr.aws/i9y2d4u3/rean-admin-portal:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
wait-for-service-stability: true
- name: Task Definition Variable
id: taskdefintionvar
shell: bash
run: |
echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition ${{ secrets.TASK_DEFINTION_NAME }} | jq '.[] | .taskDefinitionArn')" >> $GITHUB_OUTPUT
- 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 }}