Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add path check to gha #1052

Merged
merged 10 commits into from
Aug 15, 2023
Merged
30 changes: 24 additions & 6 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

on:
push:
paths:
- 'src/**'
- 'test/**'
workflow_call:
inputs:
push:
Expand Down Expand Up @@ -93,35 +98,48 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check for file changes
id: check_changes
if: ${{ !inputs.push }}
run: |
DOCKERFILE_DIR=$(dirname ${{ matrix.file_tag.file }})
FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- $DOCKERFILE_DIR)
if [ -z "$FILES_CHANGED" ]; then
echo "No changes in ${{ matrix.file_tag.context }}, skipping build."
echo "skip=true >> $GITHUB_OUTPUT"
else
echo "Changes detected in ${{ matrix.file_tag.context }}, proceeding with build."
echo "skip=false >> $GITHUB_OUTPUT"
fi
- name: Override skip for push
if: ${{ inputs.push }}
run: echo "skip=false >> $GITHUB_OUTPUT"
id: override_skip
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.push }}

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: ${{ inputs.push }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:master

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 2

max-parallelism = 2
- name: Matrix Build and push demo images
if: steps.check_changes.outputs.skip == 'false' || steps.override_skip.outputs.skip == 'false'
uses: docker/build-push-action@v3.3.1
with:
context: ${{ matrix.file_tag.context }}
Expand Down
Loading