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

Check if changed #1

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
pull_request:
workflow_dispatch:

defaults:
run:
shell: bash -leoux pipefail {0}

jobs:
docker:
runs-on: ubuntu-latest
Expand All @@ -26,12 +30,41 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
load: true
tags: ghcr.io/${{ github.repository }}:test
- name: Check if changed
id: checkchanged
run: |
mkdir tmp
cd tmp

docker pull --platform linux/amd64 ghcr.io/${{ github.repository }}:latest || exit 0
img=$(docker create --platform linux/amd64 ghcr.io/${{ github.repository }}:latest)
docker export $img -o latest.tar
docker rm $img

img=$(docker create --platform linux/amd64 ghcr.io/${{ github.repository }}:test)
docker export $img -o test.tar
docker rm $img

mkdir test
mkdir latest
tar xf test.tar -C test
tar xf latest.tar -C latest
rm -rf {test,latest}/var/{log,cache}
if diff -q -r --no-dereference test latest; then
echo "CHECKEQUALS=true" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request' && steps.checkchanged.outputs.CHECKEQUALS != 'true'
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max