-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(ci): Worker deploy queues matrix #4975
Changes from 11 commits
8d68f52
05d2ee2
340be23
89011ce
5d7523f
39163b1
0b639b6
62fa2d0
cde819f
976bd8c
2004f79
7aa11b0
090cb03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: Deploy Workers Job | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created a new resuable flow, due to the higher complexity of deploying the workers |
||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
terraform_workspace: | ||
required: true | ||
type: string | ||
docker_image: | ||
required: true | ||
type: string | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
infrastructure_data: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 80 | ||
environment: ${{ inputs.environment }} | ||
env: | ||
TF_WORKSPACE: ${{ inputs.terraform_workspace }} | ||
permissions: | ||
contents: read | ||
deployments: write | ||
outputs: | ||
services_to_deploy: ${{ steps.terraform.outputs.queue_workers_services }} | ||
ecs_cluster: ${{ steps.terraform.outputs.ecs_cluster }} | ||
aws_region: ${{ steps.terraform.outputs.aws_region }} | ||
steps: | ||
- run: echo "Deploying ${{ inputs.service_name }} to ${{ inputs.terraform_workspace }} And Docker Tag ${{ inputs.docker_image }}" | ||
- name: Checkout cloud infra | ||
uses: actions/checkout@master | ||
with: | ||
repository: novuhq/cloud-infra | ||
token: ${{ secrets.GH_PACKAGES }} | ||
path: cloud-infra | ||
|
||
- name: Terraform setup | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | ||
terraform_version: 1.5.5 | ||
terraform_wrapper: false | ||
|
||
- name: Terraform Init | ||
working-directory: cloud-infra/terraform/novu/aws | ||
run: terraform init | ||
|
||
- name: Terraform get output | ||
working-directory: cloud-infra/terraform/novu/aws | ||
id: terraform | ||
run: | | ||
echo "queue_workers_services=$(terraform output -json queue_workers_services)" >> $GITHUB_OUTPUT | ||
echo "ecs_cluster=$(terraform output -json worker_ecs_cluster | jq -r .)" >> $GITHUB_OUTPUT | ||
echo "aws_region=$(terraform output -json aws_region | jq -r .)" >> $GITHUB_OUTPUT | ||
|
||
|
||
deploy_worker_queue: | ||
needs: infrastructure_data | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 80 | ||
environment: ${{ inputs.environment }} | ||
env: | ||
TF_WORKSPACE: ${{ inputs.terraform_workspace }} | ||
permissions: | ||
contents: read | ||
deployments: write | ||
strategy: | ||
matrix: | ||
worker: ${{fromJson(needs.infrastructure_data.outputs.services_to_deploy)}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This json is located in terraform and dynamically extracts all workers we have there |
||
steps: | ||
- run: echo "Deploying ${{ matrix.name }} to ${{ inputs.terraform_workspace }} And Docker Tag ${{ inputs.docker_image }}" | ||
|
||
- 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: ${{ needs.infrastructure_data.outputs.aws_region }} | ||
|
||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition ${{ matrix.worker.task_name }} \ | ||
--query taskDefinition > task-definition.json | ||
|
||
- name: Render Amazon ECS task definition | ||
id: render-web-container | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: task-definition.json | ||
container-name: ${{ matrix.worker.container_name }} | ||
image: ${{ inputs.docker_image }} | ||
|
||
- name: Deploy to Amazon ECS service | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.render-web-container.outputs.task-definition }} | ||
service: ${{ matrix.worker.service }} | ||
cluster: ${{ needs.infrastructure_data.outputs.ecs_cluster }} | ||
wait-for-service-stability: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to use the existing reusable component instead of a duplicate here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general worker is a temporary phase until we fully migrate