forked from stripe/smokescreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
46 deletions.
There are no files selected for viewing
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
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 |