Merge branch 'next' of https://github.com/novuhq/novu into next #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy DEV WEBHOOK | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- next | |
- main | |
paths: | |
- 'package.json' | |
- 'yarn.lock' | |
- 'apps/webhook/**' | |
- 'libs/dal/**' | |
- 'libs/shared/**' | |
env: | |
TF_WORKSPACE: novu-dev | |
jobs: | |
test_webhook: | |
uses: ./.github/workflows/reusable-webhook-e2e.yml | |
deploy_dev_webhook: | |
if: "!contains(github.event.head_commit.message, 'ci skip')" | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
needs: test_webhook | |
timeout-minutes: 80 | |
environment: Development | |
permissions: | |
contents: read | |
packages: write | |
deployments: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-project | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
REGISTRY_OWNER: novuhq | |
DOCKER_NAME: novu/webhook | |
IMAGE_TAG: ${{ github.sha }} | |
GH_ACTOR: ${{ github.actor }} | |
GH_PASSWORD: ${{ secrets.GH_PACKAGES }} | |
run: | | |
echo $GH_PASSWORD | docker login ghcr.io -u $GH_ACTOR --password-stdin | |
cd apps/webhook && DOCKER_BUILDKIT=1 npm run docker:build | |
docker tag novu-webhook ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:dev | |
docker tag novu-webhook ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG | |
docker run --network=host --name webhook -dit --env NODE_ENV=test ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG | |
docker run --network=host appropriate/curl --retry 10 --retry-delay 5 --retry-connrefused http://localhost:1341/v1/health-check | grep 'ok' | |
docker push ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:dev | |
docker push ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG | |
echo "IMAGE=ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
- name: Checkout cloud infra | |
uses: actions/checkout@master | |
with: | |
repository: novuhq/cloud-infra | |
token: ${{ secrets.GH_PACKAGES }} | |
path: cloud-infra | |
- 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: eu-west-2 | |
- 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 "webhook_ecs_container_name=$(terraform output -json webhook_ecs_container_name | jq -r .)" >> $GITHUB_ENV | |
echo "webhook_ecs_service=$(terraform output -json webhook_ecs_service | jq -r .)" >> $GITHUB_ENV | |
echo "webhook_ecs_cluster=$(terraform output -json webhook_ecs_cluster | jq -r .)" >> $GITHUB_ENV | |
echo "webhook_task_name=$(terraform output -json webhook_task_name | jq -r .)" >> $GITHUB_ENV | |
- name: Download task definition | |
run: | | |
aws ecs describe-task-definition --task-definition ${{ env.webhook_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: ${{ env.webhook_ecs_container_name }} | |
image: ${{ steps.build-image.outputs.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: ${{ env.webhook_ecs_service }} | |
cluster: ${{ env.webhook_ecs_cluster }} | |
wait-for-service-stability: true |