adding create endpoint #19
This file contains hidden or 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
| on: [push] | |
| jobs: | |
| pipeline: | |
| # delete to enable deploy | |
| if: false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build | |
| run: make build-docker | |
| - name: Archive build | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: rust_server | |
| path: target/release/rust_server | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| role-to-assume: arn:aws:iam::247564283327:role/dev-admin | |
| aws-region: us-east-2 | |
| role-skip-session-tagging: true | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v1 | |
| # db-init | |
| - name: Build, tag, and push db-init image to Amazon ECR | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: pongo-postgres-0adb28f | |
| DOCKER_FILE: Dockerfile.postgres | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| docker build -f $DOCKER_FILE -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
| - name: Env substitution | |
| env: | |
| INPUT: task-definition-db-init.template.json | |
| OUTPUT: task-definition.json | |
| AWS_ACCOUNT_ID: 247564283327 | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| envsubst < $INPUT > $OUTPUT | |
| - name: Deploy to Amazon ECS | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
| with: | |
| task-definition: task-definition.json | |
| wait-for-service-stability: true | |
| - name: Execute ecs run-task db-init | |
| run: | | |
| run_task_result=$(aws ecs run-task \ | |
| --task-definition pongo-db-init \ | |
| --cluster pongo-ecs-cluster-1520594 \ | |
| --launch-type="FARGATE" \ | |
| --network-configuration '{ "awsvpcConfiguration": { "securityGroups": ["sg-0fc108c880310be04"], "subnets": ["subnet-075e79ab6b9ead172", "subnet-0548e2af7ea21ed1a"]}}') | |
| echo ${run_task_result} | |
| container_arn=$(echo $run_task_result | jq -r '.tasks[0].taskArn') | |
| echo ${container_arn} | |
| aws ecs wait tasks-stopped \ | |
| --cluster pongo-ecs-cluster-1520594 \ | |
| --tasks "${container_arn}" | |
| # migrate | |
| - name: Build, tag, and push migrate image to Amazon ECR | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: pongo-migrate-990bd9f | |
| DOCKER_FILE: Dockerfile.migrate | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| docker build -f $DOCKER_FILE -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
| - name: Env substitution | |
| env: | |
| INPUT: task-definition-migrate.template.json | |
| OUTPUT: task-definition.json | |
| AWS_ACCOUNT_ID: 247564283327 | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| envsubst < $INPUT > $OUTPUT | |
| - name: Deploy to Amazon ECS | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
| with: | |
| task-definition: task-definition.json | |
| wait-for-service-stability: true | |
| - name: Execute ecs run-task migrate | |
| run: | | |
| run_task_result=$(aws ecs run-task \ | |
| --task-definition pongo-migrate \ | |
| --cluster pongo-ecs-cluster-1520594 \ | |
| --launch-type="FARGATE" \ | |
| --network-configuration '{ "awsvpcConfiguration": { "securityGroups": ["sg-0fc108c880310be04"], "subnets": ["subnet-075e79ab6b9ead172", "subnet-0548e2af7ea21ed1a"]}}') | |
| echo ${run_task_result} | |
| container_arn=$(echo $run_task_result | jq -r '.tasks[0].taskArn') | |
| echo ${container_arn} | |
| aws ecs wait tasks-stopped \ | |
| --cluster pongo-ecs-cluster-1520594 \ | |
| --tasks "${container_arn}" | |
| # seed | |
| - name: Env substitution | |
| env: | |
| INPUT: task-definition-seed.template.json | |
| OUTPUT: task-definition.json | |
| AWS_ACCOUNT_ID: 247564283327 | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| envsubst < $INPUT > $OUTPUT | |
| - name: Deploy to Amazon ECS | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
| with: | |
| task-definition: task-definition.json | |
| wait-for-service-stability: true | |
| - name: Execute ecs run-task seed | |
| run: | | |
| run_task_result=$(aws ecs run-task \ | |
| --task-definition pongo-seed \ | |
| --cluster pongo-ecs-cluster-1520594 \ | |
| --launch-type="FARGATE" \ | |
| --network-configuration '{ "awsvpcConfiguration": { "securityGroups": ["sg-0fc108c880310be04"], "subnets": ["subnet-075e79ab6b9ead172", "subnet-0548e2af7ea21ed1a"]}}') | |
| container_arn=$(echo $run_task_result | jq -r '.tasks[0].taskArn') | |
| aws ecs wait tasks-stopped \ | |
| --cluster pongo-ecs-cluster-1520594 \ | |
| --tasks "${container_arn}" | |
| # app | |
| - name: Build, tag, and push app-rust image to Amazon ECR | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: pongo-app-rust-03c0bae | |
| DOCKER_FILE: Dockerfile.app | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| docker build -f $DOCKER_FILE -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
| - name: Env substitution | |
| env: | |
| INPUT: task-definition-app.template.json | |
| OUTPUT: task-definition.json | |
| AWS_ACCOUNT_ID: 247564283327 | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| envsubst < $INPUT > $OUTPUT | |
| - name: Deploy to Amazon ECS | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
| with: | |
| service: pongo-service-app-rust | |
| cluster: pongo-ecs-cluster-1520594 | |
| task-definition: task-definition.json | |
| wait-for-service-stability: true |