Merge pull request #4 from tangles-0/large-file-handling #50
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
| name: Deploy Dev | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| AWS_REGION: ap-southeast-2 | |
| APP_ENV: dev | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| #- name: Lint | |
| # run: pnpm lint | |
| - name: Build | |
| run: pnpm build | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_ARN_DEV }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Resolve account and image metadata | |
| id: meta | |
| run: | | |
| ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)" | |
| IMAGE_REPO="latex-${APP_ENV}-app" | |
| IMAGE_TAG="${GITHUB_SHA}" | |
| IMAGE_URI="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${IMAGE_REPO}:${IMAGE_TAG}" | |
| echo "account_id=${ACCOUNT_ID}" >> "$GITHUB_OUTPUT" | |
| echo "image_repo=${IMAGE_REPO}" >> "$GITHUB_OUTPUT" | |
| echo "image_tag=${IMAGE_TAG}" >> "$GITHUB_OUTPUT" | |
| echo "image_uri=${IMAGE_URI}" >> "$GITHUB_OUTPUT" | |
| - name: Ensure ECR repository exists | |
| run: | | |
| aws ecr describe-repositories --repository-names "${{ steps.meta.outputs.image_repo }}" >/dev/null 2>&1 || \ | |
| aws ecr create-repository --repository-name "${{ steps.meta.outputs.image_repo }}" | |
| - name: ECR login | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build and push image | |
| run: | | |
| docker build -t "${{ steps.meta.outputs.image_uri }}" . | |
| docker push "${{ steps.meta.outputs.image_uri }}" | |
| - name: Install CDK dependencies | |
| run: pnpm cdk:install | |
| - name: Deploy CDK stacks (dev) | |
| run: pnpm --dir infra/cdk exec cdk deploy --all --require-approval never -c env=dev -c imageTag=${{ steps.meta.outputs.image_tag }} -c certificateArn=${{ secrets.ACM_CERT_ARN_DEV }} | |