Merge pull request #123 from SpareCores/DEV-362 #15
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: Build and publish sc-www image for prod | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Inject legal docs | |
env: | |
LEGAL_TOKEN: ${{ secrets.LEGAL_TOKEN }} | |
LEGAL_URL: ${{ secrets.LEGAL_URL }} | |
run: 'curl -s -L -H "Authorization: token ${LEGAL_TOKEN}" ${LEGAL_URL} | tar xz --strip-components=1' | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-central-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile | |
context: . | |
push: true | |
tags: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO_NAME }}:latest | |
build-args: | | |
POSTHOG_KEY=${{ secrets.POSTHOG_KEY }} | |
POSTHOG_HOST=${{ secrets.POSTHOG_HOST }} | |
SENTRY_DSN=${{ secrets.SENTRY_DSN }} | |
SENTRY_ENVIRONMENT=production | |
SENTRY_ORG=${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }} | |
SENTRY_URL=${{ secrets.SENTRY_URL }} | |
SENTRY_RELEASE=${{ env.GITHUB_SHA }} | |
SENTRY_TRACE_SAMPLE_RATE=1 | |
SENTRY_PROFILE_SAMPLE_RATE=1 | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
SENTRY_URL: ${{ secrets.SENTRY_URL }} | |
with: | |
environment: production | |
ignore_missing: true | |
- name: Redeploy ECS service | |
env: | |
CLUSTER: ${{ secrets.ECS_CLUSTER }} | |
SERVICE: ${{ secrets.ECS_SERVICE }} | |
REGION: eu-central-1 | |
run: | | |
aws ecs update-service --cluster $CLUSTER --service $SERVICE --force-new-deployment --region $REGION |