-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (64 loc) · 2.06 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: publish
on:
schedule:
- cron: '42 02 * * *'
push:
branches: ["main"]
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash -leoux pipefail {0}
jobs:
docker:
runs-on: ubuntu-latest
concurrency: ci-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login into registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
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