name: Build Docker image on: push: branches: [master] pull_request: branches: ["*"] env: REGISTRY: ghcr.io jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Construct tags / labels for an image id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: | ${{ env.REGISTRY }}/${{ github.repository }} tags: | type=sha # https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable - name: Update environment variables run: grep -v '^#' .env >> $GITHUB_ENV - name: Setup Buildx uses: docker/setup-buildx-action@v1 - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: push: ${{ github.event_name == 'push' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | OTP_VERSION=${{ env.OTP_VERSION }} THRIFT_VERSION=${{ env.THRIFT_VERSION }} SERVICE_NAME=${{ env.SERVICE_NAME }}