chore: add tests for build docker image when dockerfile changed #5
Workflow file for this run
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 API dockerfile | |
on: | |
pull_request: | |
branches: | |
- "main" | |
paths: | |
- api/Dockerfile | |
concurrency: | |
group: docker-build-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- service_name: "build-api-amd64" | |
image_name_env: "DIFY_API_IMAGE_NAME" | |
context: "api" | |
platform: linux/amd64 | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Extract metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env[matrix.image_name_env] }} | |
- name: Build Docker image | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
push: false | |
context: "{{defaultContext}}:${{ matrix.context }}" | |
platforms: ${{ matrix.platform }} | |
build-args: COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env[matrix.image_name_env] }},push-by-digest=true,name-canonical=true,push=false | |
# cache-from: type=gha,scope=${{ matrix.service_name }} | |
# cache-to: type=gha,mode=max,scope=${{ matrix.service_name }} |