add segments #74
This file contains 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: Build and push to ECR(tokenguard-dev) | |
on: | |
push: | |
branches: ["dev"] | |
pull_request: | |
branches: ["dev"] | |
workflow_dispatch: | |
env: | |
AWS_REGION: eu-west-1 | |
jobs: | |
run-tests: | |
name: Run tests | |
if: github.event_name == 'pull_request' || github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Build Docker image | |
run: docker build -t db-api . | |
- name: Run tests with temp db | |
run: docker compose -f docker-compose-test.yaml run db-api npm test | |
- name: Remove docker and volumes | |
run: docker compose -f docker-compose-test.yaml down -v | |
build-push: | |
name: Build image and push to ECR(tokenguard-dev) | |
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
needs: run-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
# Setup hardware emulator using QEMU | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: linux/arm64,linux/amd64 | |
# Setup Docker Builderx for multi-arch images | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag and push to Amazon ECR | |
id: build-push-ecr | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.login-ecr.outputs.registry }}/tokenguard-dev-db-api:${{ github.sha }} | |
- name: Image digest | |
run: echo ${{ steps.build-push-ecr.outputs.digest }} |