From 71cc7c8df3f9663b47bc6fcc77291dbed5a657d1 Mon Sep 17 00:00:00 2001 From: Vedran Devcic Date: Thu, 6 Feb 2025 15:36:36 +0100 Subject: [PATCH 1/2] Rework deploy staging ecs and remove build and deploy --- .github/workflows/build-and-push.yml | 35 ---------- .github/workflows/deploy-staging-ecs.yml | 83 +----------------------- 2 files changed, 2 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/build-and-push.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml deleted file mode 100644 index e3765b5..0000000 --- a/.github/workflows/build-and-push.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Build and push - -on: - push: - branches: - - main - paths-ignore: - - '.github/**' - - '**.md' - workflow_dispatch: - inputs: - custom_tag: - description: 'Set custom tag for image' - required: true - type: string - -jobs: - build-and-push: - if: ${{ github.event_name == 'push' }} - name: 'Run on push' - uses: infinum/devops-pipelines/.github/workflows/docker-build-push.yml@v1.12.12 - with: - cloud: 'AWS' - environment: 'production' - secrets: inherit - - build-and-push-manual: - if: ${{ github.event_name == 'workflow_dispatch' }} - name: 'Run on workflow dispatch' - uses: infinum/devops-pipelines/.github/workflows/docker-build-push.yml@v1.12.12 - with: - cloud: 'AWS' - environment: 'production' - custom_tag: ${{ inputs.custom_tag }} - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/deploy-staging-ecs.yml b/.github/workflows/deploy-staging-ecs.yml index 0013b1e..d04a678 100644 --- a/.github/workflows/deploy-staging-ecs.yml +++ b/.github/workflows/deploy-staging-ecs.yml @@ -69,70 +69,11 @@ jobs: aws_ecr_account_id: ${{ needs.context.outputs.aws_ecr_account_id }} secrets: inherit - run-migrations: - name: Run Prisma db migrations - runs-on: ubuntu-latest - needs: [context, build-push-image] - environment: ${{ inputs.environment }} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Node - uses: actions/setup-node@v2 - with: - node-version: '20' - - name: Install dependencies - run: npm ci - - name: Open SSH tunnel - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ needs.context.outputs.aws_region }} - run: | - aws ssm start-session \ - --target i-0cb09814d228ec31d \ - --document-name AWS-StartPortForwardingSessionToRemoteHost \ - --parameters host="${{ secrets.JUMPHOST_HOST }}",portNumber="5432",localPortNumber="5432" & - sleep 10 - - name: Run migrations - env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} - run: npx prisma migrate deploy - - run-migrations-manual: - name: Run Prisma db migrations - runs-on: ubuntu-latest - needs: [context, build-push-image-manual] - environment: ${{ inputs.environment }} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Node - uses: actions/setup-node@v2 - with: - node-version: '20' - - name: Install dependencies - run: npm ci - - name: Open SSH tunnel - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ needs.context.outputs.aws_region }} - run: | - aws ssm start-session \ - --target ${{ vars.JUMPHOST_ID }} \ - --document-name AWS-StartPortForwardingSessionToRemoteHost \ - --parameters host="${{ secrets.JUMPHOST_HOST }}",portNumber="${{ vars.JUMPHOST_PORT }}",localPortNumber="${{ vars.SERVER_PORT }}" & - - name: Run migrations - env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} - run: npx prisma migrate deploy - deploy-image: if: ${{ github.event_name == 'push' }} name: Deploy backend uses: infinum/devops-pipelines/.github/workflows/deploy-ecs-task-definition.yml@v1.12.16 - needs: [context, build-push-image, run-migrations] + needs: [context, build-push-image] with: image_uri: ${{ needs.context.outputs.aws_ecr_uri }}:${{ github.sha }} environment: ${{ inputs.environment }} @@ -147,7 +88,7 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' }} name: Deploy backend uses: infinum/devops-pipelines/.github/workflows/deploy-ecs-task-definition.yml@v1.12.16 - needs: [context, build-push-image-manual, run-migrations-manual] + needs: [context, build-push-image-manual] with: image_uri: ${{ needs.context.outputs.aws_ecr_uri }}:${{ inputs.custom_tag }} environment: ${{ inputs.environment }} @@ -156,24 +97,4 @@ jobs: ecs_service: js-revisor task_def_path: .aws/ecs/task-definition-app-staging.json container_name: js-revisor - secrets: inherit - - notify-deployment-automatic: - name: Send Slack notification - uses: infinum/devops-pipelines/.github/workflows/slack-notification.yml@v1.12.16 - needs: - [ - context, - build-push-image, - build-push-image-manual, - run-migrations, - run-migrations-manual, - deploy-image, - deploy-image-manual, - ] - with: - channel: project-js-revisor-notifications - outcome: ${{ needs.build-push-image.result == 'success' || needs.build-push-image-manual.result == 'success'}} - color: ${{ needs.build-push-image.result == 'success' || needs.build-push-image-manual.result == 'success' }} - title: "[Staging] deploy js-revisor: ${{ needs.build-push-image.result == 'success' || needs.build-push-image-manual.result == 'success'}}" secrets: inherit \ No newline at end of file From 35951f4a1bc40e04bf24333e4eca3f7eab84fe81 Mon Sep 17 00:00:00 2001 From: Vedran Devcic Date: Thu, 6 Feb 2025 15:38:33 +0100 Subject: [PATCH 2/2] Fix name of app --- .github/workflows/deploy-staging-ecs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-staging-ecs.yml b/.github/workflows/deploy-staging-ecs.yml index d04a678..be35726 100644 --- a/.github/workflows/deploy-staging-ecs.yml +++ b/.github/workflows/deploy-staging-ecs.yml @@ -79,9 +79,9 @@ jobs: environment: ${{ inputs.environment }} aws_region: ${{ needs.context.outputs.aws_region }} ecs_cluster: ${{ needs.context.outputs.aws_ecs_cluster }} - ecs_service: js-revisor + ecs_service: js-react-example task_def_path: .aws/ecs/task-definition-app-staging.json - container_name: js-revisor + container_name: js-react-example secrets: inherit deploy-image-manual: @@ -94,7 +94,7 @@ jobs: environment: ${{ inputs.environment }} aws_region: ${{ needs.context.outputs.aws_region }} ecs_cluster: ${{ needs.context.outputs.aws_ecs_cluster }} - ecs_service: js-revisor + ecs_service: js-react-example task_def_path: .aws/ecs/task-definition-app-staging.json - container_name: js-revisor + container_name: js-react-example secrets: inherit \ No newline at end of file