Skip to content

Commit

Permalink
Trigger migrations from pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoVictor committed Jun 18, 2024
1 parent 9c8e6a3 commit 78cedb9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ jobs:
--parameter-overrides \
ImageUri=${{ env.REPOSITORY_URI }}:${{ github.run_id }}
migrations:
runs-on: ubuntu-latest
needs: [deploy]
steps:
- uses: aws-actions/setup-sam@v2
with:
use-installer: true

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Run migrations
run: |
aws lambda invoke \
--function-name "MigrationsFunction" \
--cli-binary-format raw-in-base64-out \
-
delete-outdated-image:
runs-on: ubuntu-latest
needs: [deploy]
Expand Down
6 changes: 1 addition & 5 deletions template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Resources:
MigrationsFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: MigrationsFunction
Handler: src/migrations.handler
MemorySize: 256
Runtime: nodejs20.x
Expand Down Expand Up @@ -58,11 +59,6 @@ Resources:
CodeUri:
Bucket: !ImportValue coderunner-CodeRunnerBucketName
Key: package/latest.zip
AutoPublishAlias: live
DeploymentPreference:
Type: AllAtOnce
Hooks:
PreTraffic: !Ref MigrationsFunction
Environment:
Variables:
NODE_ENV: production
Expand Down

0 comments on commit 78cedb9

Please sign in to comment.