From da19583c1a329bf512d8263bafda587fc3315e72 Mon Sep 17 00:00:00 2001 From: nikhilleo10 Date: Sun, 19 Nov 2023 03:56:40 +0530 Subject: [PATCH] feat: cd and update ecs deployment scripts --- .github/pull_request_template.md | 28 +++++++++++++++++++++ .github/workflows/cd-dev.yml | 42 ++++++++++++++++++++++++++++++++ .github/workflows/cd-prod.yml | 42 ++++++++++++++++++++++++++++++++ scripts/update-ecs.sh | 1 + 4 files changed, 113 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/cd-dev.yml create mode 100644 .github/workflows/cd-prod.yml create mode 100644 scripts/update-ecs.sh diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..1f8fc2d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,28 @@ +### Ticket Link + +--- + +### Related Links + +--- + +### Description + +--- + +### Steps to Reproduce / Test + +--- + +--- + +### Checklist + +- [ ] PR description included +- [ ] `yarn test` passes +- [ ] Tests are [changed or added] +- [ ] Relevant documentation is changed or added (and PR referenced) + +### GIF's + +--- diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml new file mode 100644 index 0000000..a19092c --- /dev/null +++ b/.github/workflows/cd-dev.yml @@ -0,0 +1,42 @@ +name: Deploy -> Dev +on: + push: + branches: + - develop +jobs: + deploy: + name: Deploy to ECS + runs-on: ubuntu-latest + environment: development + permissions: + deployments: write + contents: read + actions: read + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + steps: + - name: Create GitHub Deployment + uses: chrnorm/deployment-action@v2 + id: deployment + with: + token: '${{ github.token }}' + environment: development + + - name: Checkout + uses: actions/checkout@v2 + + - 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 }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Setup AWS Copilot + uses: softprops/setup-aws-copilot@v1 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + - name: Deploy ECS + run: | + ./scripts/update-ecs.sh ${{ env.ENVIRONMENT_NAME }} diff --git a/.github/workflows/cd-prod.yml b/.github/workflows/cd-prod.yml new file mode 100644 index 0000000..fff440c --- /dev/null +++ b/.github/workflows/cd-prod.yml @@ -0,0 +1,42 @@ +name: Deploy -> Dev +on: + push: + branches: + - main +jobs: + deploy: + name: Deploy to ECS + runs-on: ubuntu-latest + environment: production + permissions: + deployments: write + contents: read + actions: read + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + steps: + - name: Create GitHub Deployment + uses: chrnorm/deployment-action@v2 + id: deployment + with: + token: '${{ github.token }}' + environment: production + + - name: Checkout + uses: actions/checkout@v2 + + - 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 }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Setup AWS Copilot + uses: softprops/setup-aws-copilot@v1 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + - name: Deploy ECS + run: | + ./scripts/update-ecs.sh ${{ env.ENVIRONMENT_NAME }} diff --git a/scripts/update-ecs.sh b/scripts/update-ecs.sh new file mode 100644 index 0000000..46769f8 --- /dev/null +++ b/scripts/update-ecs.sh @@ -0,0 +1 @@ +copilot deploy --name "python-fastapi-template-$1-svc" -e $1 \ No newline at end of file