1
1
# Based heavily on the docker build action from immich (https://github.com/immich-app/immich/)
2
2
3
- name : Docker
3
+ name : Build CI and Release
4
4
5
5
on :
6
6
workflow_dispatch :
@@ -20,21 +20,23 @@ jobs:
20
20
name : Build PlatformIO
21
21
runs-on : ubuntu-latest
22
22
steps :
23
- - uses : actions/checkout@v3
24
- - uses : actions/cache@v3
23
+ - uses : actions/checkout@v4
24
+ - uses : actions/cache@v4
25
25
with :
26
26
path : |
27
27
~/.cache/pip
28
28
~/.platformio/.cache
29
29
key : ${{ runner.os }}-pio
30
- - uses : actions/setup-python@v4
31
- with :
32
- python-version : ' 3.11'
30
+ # - uses: actions/setup-python@v5
31
+ # with:
32
+ # python-version: '3.13'
33
+ - name : Install python
34
+ run : sudo apt-get install python3 python3-pip
33
35
- name : Install PlatformIO Core
34
36
run : pip install --upgrade platformio
35
37
36
38
- name : Build PlatformIO Project
37
- run : pio run --environment d1_mini
39
+ run : pio run --environment d1_mini
38
40
39
41
- name : Move and rename firmware
40
42
run : mv .pio/build/d1_mini/firmware.bin ./firmware_os_esp8266.bin
45
47
name : firmware
46
48
path : ./firmware_os_esp8266.bin
47
49
build-docker :
48
- name : Build and Push
50
+ name : Build Docker
49
51
runs-on : ubuntu-latest
50
- needs : [build-pio, build-ospi]
51
52
steps :
52
53
- name : Checkout
53
54
uses : actions/checkout@v4
@@ -58,13 +59,24 @@ jobs:
58
59
- name : Set up Docker Buildx
59
60
uses : docker/setup-buildx-action@v3
60
61
62
+ - id : lower-repo
63
+ name : Repository to lowercase
64
+ run : |
65
+ REPO=${{ github.event.repository.name }}
66
+ echo "repository=${REPO@L}" >> $GITHUB_OUTPUT
67
+
68
+ - id : lower-owner
69
+ name : Owner to lowercase
70
+ run : |
71
+ echo "owner=${GITHUB_REPOSITORY_OWNER@L}" >> $GITHUB_OUTPUT
72
+
61
73
- name : Login to GitHub Container Registry
62
74
uses : docker/login-action@v3
63
75
# Skip when PR from a fork
64
76
if : ${{ !github.event.pull_request.head.repo.fork }}
65
77
with :
66
78
registry : ghcr.io
67
- username : ${{ env.ACT && github.actor || github.repository_owner }}
79
+ username : ${{ env.ACT && github.actor || steps.lower-owner.outputs.owner }}
68
80
password : ${{ secrets.GITHUB_TOKEN }}
69
81
70
82
- name : Determine build cache output
@@ -74,31 +86,47 @@ jobs:
74
86
# Essentially just ignore the cache output (PR can't write to registry cache)
75
87
echo "cache-to=type=local,dest=/tmp/discard,ignore-error=true" >> $GITHUB_OUTPUT
76
88
else
77
- echo "cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository_owner }}/mkrcx -build-cache:${{ github.repository }} " >> $GITHUB_OUTPUT
89
+ echo "cache-to=type=registry,mode=max,ref=ghcr.io/${{ steps.lower-owner.outputs.owner }}/opensprinkler -build-cache:ospi " >> $GITHUB_OUTPUT
78
90
fi
79
91
92
+ - name : Generate docker image tags
93
+ id : metadata
94
+ uses : docker/metadata-action@v5
95
+ with :
96
+ flavor : |
97
+ latest=auto
98
+ images : |
99
+ name=ghcr.io/${{ steps.lower-owner.outputs.owner }}/${{ steps.lower-repo.outputs.repository }}
100
+ tags : |
101
+ # Tag with branch name
102
+ type=ref,event=branch
103
+ # Tag with pr-number
104
+ type=ref,event=pr
105
+ # Tag with git tag on release
106
+ type=ref,event=tag
107
+ type=raw,value=release,enable=${{ github.event_name == 'release' }}
108
+
80
109
- name : Build and push image
81
- uses : docker/build-push-action@v5.1.0
110
+ uses : docker/build-push-action@v6
82
111
with :
83
112
context : .
84
113
file : ./Dockerfile
85
114
platforms : linux/amd64,linux/arm/v7,linux/arm64
86
115
# Skip pushing when PR from a fork
87
- push : ${{ !github.event.pull_request.head.repo.fork }}
88
- output : type=docker ,dest=./output .tar
89
- cache-from : type=registry,ref=ghcr.io/${{ github.repository_owner }}/mkrcx -build-cache:${{ github.repository }}
116
+ push : false
117
+ outputs : type=oci ,dest=./image .tar
118
+ cache-from : type=registry,ref=ghcr.io/${{ steps.lower-owner.outputs.owner }}/opensprinkler -build-cache:ospi
90
119
cache-to : ${{ steps.cache-target.outputs.cache-to }}
91
120
92
121
- name : Upload image
93
122
uses : actions/upload-artifact@v4
94
123
with :
95
124
name : docker-image
96
- path : ./output.tar
97
- expire-in : 1h
125
+ path : ./image.tar
98
126
release-pio :
99
127
name : Release PlatformIO
100
128
runs-on : ubuntu-latest
101
- needs : [ build-pio build-docker ]
129
+ needs : [build-pio, build-docker]
102
130
if : ${{ github.event_name == 'release' }}
103
131
steps :
104
132
- name : Download firmware
@@ -115,56 +143,58 @@ jobs:
115
143
release-docker :
116
144
name : Release Docker
117
145
runs-on : ubuntu-latest
118
- needs : [ build-pio build-docker ]
146
+ needs : [build-pio, build-docker]
147
+ if : ${{ !github.event.pull_request.head.repo.fork }}
119
148
steps :
120
- - name : Download docker image
121
- uses : actions/download-artifact@v4
122
- with :
123
- name : docker-image
124
-
125
- - name : Login to GitHub Container Registry
126
- uses : docker/login-action@v3
127
- # Skip when PR from a fork
128
- if : ${{ !github.event.pull_request.head.repo.fork }}
129
- with :
130
- registry : ghcr.io
131
- username : ${{ env.ACT && github.actor || github.repository_owner }}
132
- password : ${{ secrets.GITHUB_TOKEN }}
133
-
134
- - name : Login to GitHub Container Registry
135
- uses : docker/login-action@v3
136
- # Skip when PR from a fork
137
- if : ${{ !github.event.pull_request.head.repo.fork }}
138
- with :
139
- registry : ghcr.io
140
- username : ${{ env.ACT && github.actor || github.repository_owner }}
141
- password : ${{ secrets.GITHUB_TOKEN }}
142
-
143
- - name : Generate docker image tags
144
- id : metadata
145
- uses : docker/metadata-action@v5
146
- with :
147
- flavor : |
148
- latest=auto
149
- images : |
150
- name=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}
151
- tags : |
152
- # Tag with branch name
153
- type=ref,event=branch
154
- # Tag with pr-number
155
- type=ref,event=pr
156
- # Tag with git tag on release
157
- type=ref,event=tag
158
- type=raw,value=release,enable=${{ github.event_name == 'release' }}
159
-
160
- - name : Load image
161
- run : docker load -i ./docker-image/output.tar
162
-
163
- - name : Build and push
164
- uses : docker/build-push-action@v6
165
- with :
166
- platforms : linux/amd64,linux/arm/v7,linux/arm64
167
- # Skip pushing when PR from a fork
168
- push : ${{ !github.event.pull_request.head.repo.fork }}
169
- tags : ${{ steps.metadata.outputs.tags }}
170
- labels : ${{ steps.metadata.outputs.labels }}
149
+ - name : Set up QEMU
150
+ uses : docker/setup-qemu-action@v3
151
+
152
+ - name : Set up Docker Buildx
153
+ uses : docker/setup-buildx-action@v3
154
+
155
+ - id : lower-repo
156
+ name : Repository to lowercase
157
+ run : |
158
+ REPO=${{ github.event.repository.name }}
159
+ echo "repository=${REPO@L}" >> $GITHUB_OUTPUT
160
+
161
+ - id : lower-owner
162
+ name : Owner to lowercase
163
+ run : |
164
+ echo "owner=${GITHUB_REPOSITORY_OWNER@L}" >> $GITHUB_OUTPUT
165
+
166
+ - name : Login to GitHub Container Registry
167
+ uses : docker/login-action@v3
168
+ # Skip when PR from a fork
169
+ if : ${{ !github.event.pull_request.head.repo.fork }}
170
+ with :
171
+ registry : ghcr.io
172
+ username : ${{ env.ACT && github.actor || steps.lower-owner.outputs.owner }}
173
+ password : ${{ secrets.GITHUB_TOKEN }}
174
+
175
+ - name : Generate docker image tags
176
+ id : metadata
177
+ uses : docker/metadata-action@v5
178
+ with :
179
+ flavor : |
180
+ latest=auto
181
+ images : |
182
+ name=ghcr.io/${{ steps.lower-owner.outputs.owner }}/${{ steps.lower-repo.outputs.repository }}
183
+ tags : |
184
+ # Tag with branch name
185
+ type=ref,event=branch
186
+ # Tag with pr-number
187
+ type=ref,event=pr
188
+ # Tag with git tag on release
189
+ type=ref,event=tag
190
+ type=raw,value=release,enable=${{ github.event_name == 'release' }}
191
+
192
+ - name : Push image
193
+ uses : docker/build-push-action@v6
194
+ with :
195
+ platforms : linux/amd64,linux/arm/v7,linux/arm64
196
+ # Skip pushing when PR from a fork
197
+ push : true
198
+ cache-from : type=registry,ref=ghcr.io/${{ steps.lower-owner.outputs.owner }}/opensprinkler-build-cache:ospi
199
+ tags : ${{ steps.metadata.outputs.tags }}
200
+ labels : ${{ steps.metadata.outputs.labels }}
0 commit comments