Skip to content

Commit

Permalink
do not rebuild for readme-only changes
Browse files Browse the repository at this point in the history
  • Loading branch information
builder555 committed Dec 8, 2023
1 parent b7fe50a commit 279559c
Showing 1 changed file with 45 additions and 21 deletions.
66 changes: 45 additions & 21 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,53 @@ name: Build and Push Docker Image

on:
push:
branches:
- main # or any other branch you want to trigger on
branches:
- main

jobs:
build-and-push:
ignore-readme-only-changes:
runs-on: ubuntu-latest

outputs:
run_build: ${{ steps.filter.outputs.run_build }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: builder555
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Check out the repo
uses: actions/checkout@v2
- id: filter
name: Check if README.md was updated
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -iqvE '^(readme.md)$'
then
echo "::set-output name=run_build::true"
else
echo "::set-output name=run_build::false"
fi
- name: Build and push multi-platform Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: builder555/pricewatch:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-and-push:
needs: ignore-readme-changes
if: needs.check-modified-files.outputs.run_build == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Check for README.md changes
id: readme_check
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -v 'README.md'
then
echo "README_CHANGE=false" >> $GITHUB_ENV
else
echo "README_CHANGE=true" >> $GITHUB_ENV
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: builder555
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push multi-platform Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: builder555/pricewatch:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7

0 comments on commit 279559c

Please sign in to comment.