This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
Move RegistrationTable back into wca-registrations #112
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: Deployment to Staging | |
on: | |
issue_comment: | |
types: | |
- created | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger deployment on comment | |
id: trigger-deployment | |
uses: shanegenschaw/pull-request-comment-trigger@v2.1.0 | |
with: | |
trigger: '@thewca-bot deploy staging' | |
reaction: rocket | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get ref from pr | |
id: comment-branch | |
uses: xt0rted/pull-request-comment-branch@v2 | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.comment-branch.outputs.head_ref }} | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
- 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 }} | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
- name: Deploy if triggered | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
env: | |
CLUSTER_NAME: wca-registration-staging | |
run: | | |
docker build -f dockerfile.handler -t wca-registration-handler . | |
docker build -f dockerfile.worker -t wca-registration-worker . | |
docker tag wca-registration-handler:latest ${{ steps.login-ecr.outputs.registry }}/wca-registration-handler:staging | |
docker tag wca-registration-worker:latest ${{ steps.login-ecr.outputs.registry }}/wca-registration-worker:staging | |
docker push ${{ steps.login-ecr.outputs.registry }}/wca-registration-handler:staging | |
docker push ${{ steps.login-ecr.outputs.registry }}/wca-registration-worker:staging | |
aws ecs update-service --cluster ${{ env.CLUSTER_NAME }} --service Staging-Service --force-new-deployment --desired-count 1 | |
- name: Deploy Frontend | |
if: steps.trigger-deployment.outputs.triggered == 'true' | |
run: | | |
cd ./Frontend | |
npm install | |
npm run build:staging | |
aws s3 sync dist s3://assets.registration.worldcubeassociation.org/staging/dist | |
aws cloudfront create-invalidation --distribution-id E322K044MBR5FG --paths "/staging/dist/*" --output text |