Skip to content

Commit

Permalink
chore(ci): enable PR docker build if docker/ folder was touched.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Apr 19, 2024
1 parent a26bb1b commit eb58aec
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ jobs:
with:
arch: ${{ matrix.arch }}

paths-filter:
runs-on: ubuntu-latest
outputs:
docker_needs_build: ${{ steps.filter.outputs.docker == 'true' }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: filter
with:
filters: |
docker:
- 'docker/**'
build-images-dev:
needs: [build-test-dev,paths-filter]
if: needs.paths-filter.outputs.docker_needs_build
strategy:
matrix:
arch: [ amd64, arm64 ]
uses: ./.github/workflows/reusable_build_push_images.yml
with:
arch: ${{ matrix.arch }}
push: false
secrets: inherit

gomodtidy:
name: Enforce go.mod tidiness
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ jobs:
arch: ${{ matrix.arch }}

push-images-master:
needs: build-test-master
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_push_images.yml
needs: build-test-master
with:
arch: ${{ matrix.arch }}
push: true
secrets: inherit

images-master:
uses: ./.github/workflows/reusable_manifest_images.yml
needs: push-images-master
uses: ./.github/workflows/reusable_manifest_images.yml
secrets: inherit


5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ jobs:
arch: ${{ matrix.arch }}

push-images-release:
needs: build-test-release
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_push_images.yml
needs: build-test-release
with:
arch: ${{ matrix.arch }}
tag: ${{ github.ref_name }}
is_latest: true
push: true
secrets: inherit

images-release:
uses: ./.github/workflows/reusable_manifest_images.yml
needs: push-images-release
uses: ./.github/workflows/reusable_manifest_images.yml
with:
tag: ${{ github.ref_name }}
is_latest: true
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/reusable_build_push_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
required: false
type: boolean
default: false
push:
description: Whether to also push images
required: false
type: boolean
default: false

jobs:
build-images:
Expand Down Expand Up @@ -48,14 +53,20 @@ jobs:
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Login to Docker Hub
if: inputs.push
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_SECRET }}

- name: Build and Push docker images
if: inputs.push
run: make push/all


- name: Build docker images
if: inputs.push == false
run: make build/all

- name: Push latest images if needed
if: inputs.is_latest
if: inputs.push && inputs.is_latest
run: make push/latest

0 comments on commit eb58aec

Please sign in to comment.