protobuf websocket, websocket testing tool wip #70
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: Run migrations on RDS database | ||
on: | ||
push: | ||
if: ${{ false }} # Disable for now | ||
branches: [ "main" ] | ||
paths: | ||
- migrations/** | ||
- deployment/general/migrate/** | ||
- deployment/dev/migrate/** | ||
- deployment/prod/migrate/** | ||
- .github/workflows/migrate.yml | ||
env: | ||
AWS_REGION: ${{ vars.AWS_REGION }} # set this to your preferred AWS region, e.g. us-west-1 | ||
REGISTRY: ghcr.io | ||
IMAGE: p2pcv-migrate | ||
FULL_IMAGE: ghcr.io/relacibo/p2pcv-migrate-dev | ||
ECS_CLUSTER: ${{ vars.AWS_ECS_CLUSTER }} # set this to your Amazon ECS cluster name | ||
ECS_TASK_DEFINITION: deployment/dev/migrate/task-definition.json # set this to the path to your Amazon ECS task definition | ||
# file, e.g. .aws/task-definition.json | ||
CONTAINER_NAME: p2pcv-migrate-dev # set this to the name of the container in the | ||
# containerDefinitions section of your task definition | ||
permissions: | ||
contents: read | ||
concurrency: | ||
group: migrate-dev | ||
cancel-in-progress: true | ||
jobs: | ||
check-build-condition: | ||
name: Check if we should build image | ||
runs-on: ubuntu-latest | ||
environment: dev | ||
permissions: | ||
contents: read | ||
outputs: | ||
migrate: ${{ steps.filter.outputs.migrate }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Check if something changed in migrate folders | ||
uses: dorny/paths-filter@v2 | ||
id: filter | ||
with: | ||
filters: | | ||
migrate: | ||
- 'deployment/general/migrate/**' | ||
- 'deployment/dev/migrate/**' | ||
- 'deployment/prod/migrate/**' | ||
build: | ||
name: Build migration image | ||
needs: check-build-condition | ||
if: ${{ needs.check-build-condition.outputs.migrate == 'true' }} | ||
runs-on: ubuntu-latest | ||
environment: dev | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./deployment/general/migrate/Dockerfile | ||
push: true | ||
tags: ${{ env.FULL_IMAGE }}:latest | ||
migrate: | ||
name: Migrate | ||
needs: build | ||
if: always() | ||
runs-on: ubuntu-latest | ||
environment: dev | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ vars.AWS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ${{ env.ECS_TASK_DEFINITION }} | ||
container-name: ${{ env.CONTAINER_NAME }} | ||
image: ${{ env.FULL_IMAGE }}:latest | ||
environment-variables: | | ||
GIT_REPOSITORY=${{github.server_url}}/${{github.repository}} | ||
GIT_COMMIT=${{github.sha}} | ||
- name: Run Task on Amazon ECS | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v2 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
cluster: ${{ env.ECS_CLUSTER }} | ||
run-task: true | ||
run-task-subnets: ${{ vars.AWS_MIGRATE_SUBNETS }} | ||
run-task-assign-public-IP: ENABLED | ||
run-task-security-groups: ${{ vars.AWS_MIGRATE_SECURITY_GROUPS }} | ||
run-task-launch-type: FARGATE | ||
wait-for-task-stopped: true | ||