Skip to content

Deploy Main to Staging Manually #7

Deploy Main to Staging Manually

Deploy Main to Staging Manually #7

name: Deploy Main to Staging Manually
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.CI_CD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CI_CD_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Get the SHA of the current branch/fork
shell: bash
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
- name: Build and Push Sidekiq image
uses: docker/build-push-action@v6
with:
push: true
target: sidekiq
tags: |
${{ steps.login-ecr.outputs.registry }}/wca-on-rails:sidekiq-staging
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TAG=${{ env.SHORT_SHA }}
WCA_LIVE_SITE=false
SHAKAPACKER_ASSET_HOST=https://staging-assets.worldcubeassociation.org
- name: Build and push Staging Image
id: build-staging
uses: docker/build-push-action@v6
with:
push: true
load: true
target: monolith
tags: |
${{ steps.login-ecr.outputs.registry }}/wca-on-rails:staging
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TAG=${{ env.SHORT_SHA }}
WCA_LIVE_SITE=false
SHAKAPACKER_ASSET_HOST=https://staging-assets.worldcubeassociation.org
# We build assets in docker and copy it out so we don't have to install all the dependencies in the GH Action
- name: Copy assets out of the container and push to S3
run: |
id=$(docker create ${{steps.build-staging.outputs.imageid }})
docker cp $id:/rails/public/ ./assets
aws s3 sync ./assets s3://assets-staging.worldcubeassociation.org/assets/${{ env.SHORT_SHA }}
# There is no pipeline for staging so we manually force to update the image
- name: Deploy staging
run: |
aws ecs update-service --cluster wca-on-rails --service wca-on-rails-staging --force-new-deployment