Skip to content

Commit

Permalink
ci: adds github workflow for triggering ECS service update (#29)
Browse files Browse the repository at this point in the history
Closes #26
  • Loading branch information
yosefmaru authored Nov 15, 2024
2 parents a47b17c + ae4a819 commit eb90052
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Rename package
run: |
pkg_name=$(echo "${REPO_NAME}" | tr - _)
Expand Down
33 changes: 30 additions & 3 deletions .github/workflows/publish_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
- dev

jobs:
publish_ghcr:
publish_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -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-metadata-viz:dev
tags: ghcr.io/allenneuraldynamics/aind-metadata-viz: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@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- 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
37 changes: 32 additions & 5 deletions .github/workflows/tag_and_publish_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ env.DEFAULT_BRANCH }}
fetch-depth: 0
token: ${{ secrets.SERVICE_TOKEN }}
- name: Set up Python 3.10
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Pull latest changes
run: git pull origin main
- name: Set up Python 3.10
Expand All @@ -87,10 +87,10 @@ 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
- uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -107,3 +107,30 @@ jobs:
context: .
push: true
tags: ghcr.io/allenneuraldynamics/aind-metadata-viz: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@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- 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
4 changes: 2 additions & 2 deletions .github/workflows/test_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down

0 comments on commit eb90052

Please sign in to comment.