Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework deploy staging ecs and remove build and deploy #77

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/workflows/build-and-push.yml

This file was deleted.

91 changes: 6 additions & 85 deletions .github/workflows/deploy-staging-ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,111 +69,32 @@ 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/[email protected]
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 }}
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:
if: ${{ github.event_name == 'workflow_dispatch' }}
name: Deploy backend
uses: infinum/devops-pipelines/.github/workflows/[email protected]
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 }}
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
secrets: inherit

notify-deployment-automatic:
name: Send Slack notification
uses: infinum/devops-pipelines/.github/workflows/[email protected]
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'}}"
container_name: js-react-example
secrets: inherit