Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
OTEL_TAG:
type: 'string'
required: true
PUSH_TO_ECR:
type: 'boolean'
required: false
default: true
secrets:
AWS_ACCESS_KEY_ID:
required: true
Expand All @@ -40,13 +44,15 @@ jobs:
chmod +x $HOME/.local/bin/ecs-deploy

- name: Login to GitHub Container Registry
if: ${{ inputs.PUSH_TO_ECR == true }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
Comment thread
7dev7urandom marked this conversation as resolved.

- name: Pull from GHCR
if: ${{ inputs.PUSH_TO_ECR == true }}
run: |
docker pull ${{ inputs.BUILD_ENGINE_TAG }}
docker pull ${{ inputs.OTEL_TAG }}
Expand All @@ -62,18 +68,21 @@ jobs:

- name: Login to AWS ECR
id: ecr
if: ${{ inputs.PUSH_TO_ECR == true }}
uses: aws-actions/amazon-ecr-login@v2
with:
registries: ${{ secrets.AWS_ECR_ACCOUNT }}

- name: Build deployment target variables
id: vars
if: ${{ inputs.PUSH_TO_ECR == true }}
run: |
echo "Setting up deployment variables..."
echo "IMAGE_URL=${{ steps.ecr.outputs.registry }}/appbuilder-buildengine-api" >> $GITHUB_OUTPUT
echo "OTEL_URL=${{ steps.ecr.outputs.registry }}/appbuilder-buildengine-otel" >> $GITHUB_OUTPUT

- name: Push to AWS ECR
if: ${{ inputs.PUSH_TO_ECR == true }}
run: |
docker tag ${{ inputs.BUILD_ENGINE_TAG}} "${{ steps.vars.outputs.IMAGE_URL }}:${{ inputs.DOCKER_TAG }}"
docker tag ${{ inputs.BUILD_ENGINE_TAG}} "${{ steps.vars.outputs.IMAGE_URL }}:${{ inputs.BUILD_NUMBER }}"
Expand All @@ -92,6 +101,8 @@ jobs:
- name: Deploy to ECS
if: ${{ inputs.ECS_CLUSTER != 'none' }}
run: |
echo "Deploying ${{ inputs.BUILD_NUMBER }} to ${{ inputs.ECS_CLUSTER }}"
echo "Deploying ${{ inputs.PUSH_TO_ECR && inputs.BUILD_NUMBER || inputs.DOCKER_TAG }} from ${{ inputs.PUSH_TO_ECR && 'ECR' || 'GHCR' }} to ${{ inputs.ECS_CLUSTER }}"
# Deploy to ECS cluster with service name 'build-engine', setting all images to the latest tag
ecs-deploy -c ${{ inputs.ECS_CLUSTER }} -n buildengine -i ignore -to ${{ inputs.BUILD_NUMBER }} --max-definitions 20 --timeout 600
# Some deployments use images from GHCR, some from ECR. If PUSH_TO_ECR is true, we use the ECR images; otherwise, we use the GHCR images.
# GHCR images are tagged with DOCKER_TAG ("staging" or "production"), while ECR images are tagged with BUILD_NUMBER (the GitHub Actions run number).
ecs-deploy -c ${{ inputs.ECS_CLUSTER }} -n buildengine -i ignore -to ${{ inputs.PUSH_TO_ECR && inputs.BUILD_NUMBER || inputs.DOCKER_TAG }} --max-definitions 20 --timeout 600
26 changes: 7 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,21 @@ jobs:
AWS_ECR_ACCOUNT: ${{ secrets.SIL__AWS_ECR_ACCOUNT }}
deploy-fcbh:
needs: push-to-ghcr
if: false # Temporarily disabled - remove this line to re-enable
# if: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER == 'scriptoria-prd' }} # Restore this when re-enabling
if: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER == 'scriptoria-prd' }}
uses: "./.github/workflows/deploy.yml"
with:
BUILD_NUMBER: ${{ github.run_number }}
ECS_CLUSTER: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER }}
DOCKER_TAG: ${{ needs.push-to-ghcr.outputs.DOCKER_TAG }}
PUSH_TO_ECR: false

# Unused
BUILD_NUMBER: ${{ github.run_number }}
# Unused
BUILD_ENGINE_TAG: ${{ needs.push-to-ghcr.outputs.BUILD_ENGINE_TAG }}
# Unused
OTEL_TAG: ${{ needs.push-to-ghcr.outputs.OTEL_TAG }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.FCBH__AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.FCBH__AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.FCBH__AWS_DEFAULT_REGION }}
AWS_ECR_ACCOUNT: ${{ secrets.FCBH__AWS_ECR_ACCOUNT }}
deploy-lu:
needs: push-to-ghcr
if: false # Temporarily disabled - remove this line to re-enable
# if: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER == 'scriptoria-stg' }} # Restore this when re-enabling
uses: "./.github/workflows/deploy.yml"
with:
BUILD_NUMBER: ${{ github.run_number }}
ECS_CLUSTER: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER }}
DOCKER_TAG: ${{ needs.push-to-ghcr.outputs.DOCKER_TAG }}
BUILD_ENGINE_TAG: ${{ needs.push-to-ghcr.outputs.BUILD_ENGINE_TAG }}
OTEL_TAG: ${{ needs.push-to-ghcr.outputs.OTEL_TAG }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.LU__AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LU__AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.LU__AWS_DEFAULT_REGION }}
AWS_ECR_ACCOUNT: ${{ secrets.LU__AWS_ECR_ACCOUNT }}
Loading