Merge pull request #1 from growthbook/ji/add-dockerfile-and-deploy-yml #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 | |
on: | |
# Push to the main branch | |
push: | |
branches: | |
- main | |
jobs: | |
# Build and publish the commit to docker | |
docker: | |
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: 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 | |
run: aws ecs update-service --cluster prod-smokescreen --service prod-smokescreen --force-new-deployment --region us-east-1 |