diff --git a/.github/workflows/publish_dev.yml b/.github/workflows/publish_dev.yml index 9fd5d01..7210ffd 100644 --- a/.github/workflows/publish_dev.yml +++ b/.github/workflows/publish_dev.yml @@ -5,7 +5,7 @@ on: - dev jobs: - publish_ghcr: + publish_image: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -24,4 +24,31 @@ jobs: # relative path to the place where source code with Dockerfile is located context: . push: true - tags: ghcr.io/allenneuraldynamics/aind-qc-portal:dev \ No newline at end of file + tags: ghcr.io/allenneuraldynamics/aind-qc-portal:dev + update_ecs_service : + runs-on: ubuntu-latest + needs: publish_image + permissions: + id-token: write + contents: read + env: + AWS_IAM_ROLE: ${{ secrets.AWS_IAM_ROLE_DEV }} + AWS_REGION : ${{ vars.AWS_REGION }} + AWS_ECS_CLUSTER : ${{ vars.AWS_ECS_CLUSTER_DEV }} + AWS_ECS_SERVICE : ${{ vars.AWS_ECS_SERVICE_DEV }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.AWS_IAM_ROLE }} + role-session-name: github-ecs-update-service + aws-region: ${{ env.AWS_REGION }} + - name: Update ECS service + run: | + python -m pip install awscli + aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $AWS_ECS_SERVICE --force-new-deployment diff --git a/.github/workflows/tag_and_publish_main.yml b/.github/workflows/tag_and_publish_main.yml index 664efb2..6809c9a 100644 --- a/.github/workflows/tag_and_publish_main.yml +++ b/.github/workflows/tag_and_publish_main.yml @@ -87,7 +87,7 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.AIND_PYPI_TOKEN }} - publish_ghcr: + publish_image: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -107,3 +107,30 @@ jobs: context: . push: true tags: ghcr.io/allenneuraldynamics/aind-qc-portal:latest + update_ecs_service : + runs-on: ubuntu-latest + needs: publish_image + permissions: + id-token: write + contents: read + env: + AWS_IAM_ROLE: ${{ secrets.AWS_IAM_ROLE_PROD }} + AWS_REGION : ${{ vars.AWS_REGION }} + AWS_ECS_CLUSTER : ${{ vars.AWS_ECS_CLUSTER_PROD }} + AWS_ECS_SERVICE : ${{ vars.AWS_ECS_SERVICE_PROD }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.AWS_IAM_ROLE }} + role-session-name: github-ecs-update-service + aws-region: ${{ env.AWS_REGION }} + - name: Update ECS service + run: | + python -m pip install awscli + aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $AWS_ECS_SERVICE --force-new-deployment