Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add Inferable cloud deployment step #147

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
cli: ${{ steps.filter.outputs.cli }}
control_plane: ${{ steps.filter.outputs.control_plane }}
app: ${{ steps.filter.outputs.app }}
# Deploy steps (Docker build / CFN) if either control-plane or app changed
deploy: ${{ steps.filter.outputs.deploy }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -50,6 +52,9 @@ jobs:
- 'control-plane/**'
app:
- 'app/**'
deploy:
- 'control-plane/**'
- 'app/**'

build-control-plane:
needs: check_changes
Expand Down Expand Up @@ -404,7 +409,8 @@ jobs:

build-app-image:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: check_changes
if: ${{ needs.check_changes.outputs.deploy == 'true' && github.ref == 'refs/heads/main' }}
permissions:
id-token: write
steps:
Expand Down Expand Up @@ -449,7 +455,8 @@ jobs:

build-control-plane-image:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: check_changes
if: ${{ needs.check_changes.outputs.deploy == 'true' && github.ref == 'refs/heads/main' }}
permissions:
id-token: write
steps:
Expand Down Expand Up @@ -495,3 +502,50 @@ jobs:
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $DOCKERHUB_USERNAME/control-plane:latest
docker push $DOCKERHUB_USERNAME/control-plane:$IMAGE_TAG
docker push $DOCKERHUB_USERNAME/control-plane:latest

deploy-cloud:
runs-on: ubuntu-latest
if: ${{ needs.check_changes.outputs.deploy == 'true' && github.ref == 'refs/heads/main' }}
needs:
[check_changes, build-app-image, build-control-plane-image]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Notify start deploy to Rollbar
uses: rollbar/[email protected]
id: rollbar_pre_deploy
with:
environment: 'production'
version: ${{ github.sha }}
status: 'started'
env:
ROLLBAR_ACCESS_TOKEN: ${{ secrets.CLOUD_ROLLBAR_ACCESS_TOKEN }}
ROLLBAR_USERNAME: ${{ github.actor }}
- name: Deploy to AWS CloudFormation
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: "prod-inferable"
role-arn: ${{ secrets.CLOUD_AWS_CFN_ROLE_ARN }}
template: ${{ secrets.CLOUD_AWS_CFN_TEMPLATE }}
tags: "Environment=prod"
capabilities: "CAPABILITY_NAMED_IAM,CAPABILITY_IAM"
parameter-overrides: >-
Environment=prod,
ApiImageTag=${{ github.sha }},
AppImageTag=${{ github.sha }}
- name: Notify finish deploy to Rollbar
uses: rollbar/[email protected]
id: rollbar_post_deploy
with:
environment: 'production'
version: ${{ github.sha }}
status: 'succeeded'
env:
ROLLBAR_ACCESS_TOKEN: ${{ secrets.CLOUD_ROLLBAR_ACCESS_TOKEN }}
ROLLBAR_USERNAME: ${{ github.actor }}
DEPLOY_ID: ${{ steps.rollbar_pre_deploy.outputs.deploy_id }}