Skip to content

Commit

Permalink
update deploy to use ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
tzjames committed Jun 26, 2024
1 parent 0cec9c9 commit 1ea1b0a
Showing 1 changed file with 23 additions and 46 deletions.
69 changes: 23 additions & 46 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,40 @@
name: Deploy

on:
# Push to the main branch
push:
branches:
- main

jobs:
# Build and publish the commit to docker
docker:
build-node:
runs-on: ubuntu-latest
if: ${{ github.repository == 'growthbook/smokescreen' }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Install Depot CLI
uses: depot/setup-action@v1

- name: Prepare build metadata
id: metadata
run: |
# Store current git hash and date in files
mkdir -p buildinfo
echo "${GITHUB_SHA}" > buildinfo/SHA
printf '%(%Y-%m-%dT%H:%M:%SZ)T' > buildinfo/DATE
echo "sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

- name: Build, tag, and push image to Docker Hub
uses: depot/build-push-action@v1
with:
push: true
context: .
project: vmp2ssvj9r
tags: |
growthbook/smokescreen:latest
growthbook/smokescreen:git-${{ steps.metadata.outputs.sha }}
platforms: linux/amd64

# Deploy Smokescreen to AWS ECS
prod:
runs-on: ubuntu-latest
needs: [docker]
if: ${{ github.repository == 'growthbook/smokescreen' }}
steps:
- name: Configure AWS credentials for GrowthBook Cloud
- uses: actions/checkout@v1

- 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: us-east-1

- name: Deploy docker image to ECS for GrowthBook Cloud API
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: smokescreen
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and push it to ECR so that it can be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Deploy to ECS
id: deploy-ecs
run: aws ecs update-service --cluster prod-smokescreen --service prod-smokescreen --force-new-deployment --region us-east-1

0 comments on commit 1ea1b0a

Please sign in to comment.