Skip to content

api - deploy: @quoll/[email protected]

api - deploy: @quoll/[email protected] #14

Workflow file for this run

name: api - deploy
run-name: "api - deploy: ${{ github.ref_name }}"
on:
push:
tags:
- "@quoll/api@*"
workflow_dispatch:
inputs:
git-tag:
description: The formatted git tag.
required: true
type: string
permissions:
id-token: write
jobs:
docker-build-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get version
id: extract-version
uses: ./.github/actions/extract-version
continue-on-error: false
with:
tag: "${{ inputs.git-tag }}"
- name: Make image tag
id: make-image-tag
shell: bash
env:
DOCKER_IMAGE_TAG_PREFIX: quoll-api
# e.g. some-package-0.0.1
run: |
echo "image-tag=${{ env.DOCKER_IMAGE_TAG_PREFIX }}-${{ steps.extract-version.outputs.version }}" >> "$GITHUB_OUTPUT"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
env:
AWS_REGION: "us-east-1"
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_GITHUB_OIDC_ROLE_NAME }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registries: ${{ secrets.AWS_ACCOUNT_ID }}
mask-password: "true"
- name: Build, tag, and push image to Amazon ECR
id: build-publish
shell: bash
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: ${{ steps.make-image-tag.outputs.image-tag }}
DOCKERFILE_PATH: "./packages/api/Dockerfile"
run: |
docker build . -f "${{ env.DOCKERFILE_PATH }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
echo "IMAGE $IMAGE_TAG is pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
echo "image_tag=$IMAGE_TAG"
echo "full_image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"