SyncM8/syncm8

View on GitHub
.github/workflows/devDockerBuild.yml

Summary

Maintainability
Test Coverage
name: Dev Docker Build

on:
  push:
    branches: [ main ]
  workflow_dispatch:

jobs:
  build-img:
    runs-on: ubuntu-latest
    environment: prod

    steps:
      - uses: actions/checkout@v2

      - name: Populate DEVBOX_VERSION into env
        run: |
          echo "DEVBOX_VERSION=$(cat DEVBOX_VERSION)"  >> $GITHUB_ENV

      - name: Check If Dockerfile has changed
        uses: technote-space/get-diff-action@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          PATTERNS: Dockerfile

      - name: Login to Public ECR
        if: env.GIT_DIFF
        uses: docker/login-action@v1
        with:
          registry: public.ecr.aws
          username: ${{ secrets.AWS_ACCESS_KEY_ID }}
          password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        env:
          AWS_REGION: us-east-1

      - name: Build and push image
        if: env.GIT_DIFF
        uses: docker/build-push-action@v2
        with:
          pull: true # pull new intermediate images
          push: true # push to ECR
          tags: public.ecr.aws/a5f0m6q3/syncm8_dev:${{env.DEVBOX_VERSION}}
          file: Dockerfile
          target: dev