Skip to content

Commit 7129e39

Browse files
committed
fixed build yml
1 parent d98eb22 commit 7129e39

File tree

1 file changed

+100
-70
lines changed

1 file changed

+100
-70
lines changed

.github/workflows/build-ci.yml

Lines changed: 100 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Based heavily on the docker build action from immich (https://github.com/immich-app/immich/)
22

3-
name: Docker
3+
name: Build CI and Release
44

55
on:
66
workflow_dispatch:
@@ -20,21 +20,23 @@ jobs:
2020
name: Build PlatformIO
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v3
24-
- uses: actions/cache@v3
23+
- uses: actions/checkout@v4
24+
- uses: actions/cache@v4
2525
with:
2626
path: |
2727
~/.cache/pip
2828
~/.platformio/.cache
2929
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
3335
- name: Install PlatformIO Core
3436
run: pip install --upgrade platformio
3537

3638
- name: Build PlatformIO Project
37-
run: pio run --environment d1_mini
39+
run: pio run --environment d1_mini
3840

3941
- name: Move and rename firmware
4042
run: mv .pio/build/d1_mini/firmware.bin ./firmware_os_esp8266.bin
@@ -45,9 +47,8 @@ jobs:
4547
name: firmware
4648
path: ./firmware_os_esp8266.bin
4749
build-docker:
48-
name: Build and Push
50+
name: Build Docker
4951
runs-on: ubuntu-latest
50-
needs: [build-pio, build-ospi]
5152
steps:
5253
- name: Checkout
5354
uses: actions/checkout@v4
@@ -58,13 +59,24 @@ jobs:
5859
- name: Set up Docker Buildx
5960
uses: docker/setup-buildx-action@v3
6061

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+
6173
- name: Login to GitHub Container Registry
6274
uses: docker/login-action@v3
6375
# Skip when PR from a fork
6476
if: ${{ !github.event.pull_request.head.repo.fork }}
6577
with:
6678
registry: ghcr.io
67-
username: ${{ env.ACT && github.actor || github.repository_owner }}
79+
username: ${{ env.ACT && github.actor || steps.lower-owner.outputs.owner }}
6880
password: ${{ secrets.GITHUB_TOKEN }}
6981

7082
- name: Determine build cache output
@@ -74,31 +86,47 @@ jobs:
7486
# Essentially just ignore the cache output (PR can't write to registry cache)
7587
echo "cache-to=type=local,dest=/tmp/discard,ignore-error=true" >> $GITHUB_OUTPUT
7688
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
7890
fi
7991
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+
80109
- name: Build and push image
81-
uses: docker/build-push-action@v5.1.0
110+
uses: docker/build-push-action@v6
82111
with:
83112
context: .
84113
file: ./Dockerfile
85114
platforms: linux/amd64,linux/arm/v7,linux/arm64
86115
# 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
90119
cache-to: ${{ steps.cache-target.outputs.cache-to }}
91120

92121
- name: Upload image
93122
uses: actions/upload-artifact@v4
94123
with:
95124
name: docker-image
96-
path: ./output.tar
97-
expire-in: 1h
125+
path: ./image.tar
98126
release-pio:
99127
name: Release PlatformIO
100128
runs-on: ubuntu-latest
101-
needs: [ build-pio build-docker ]
129+
needs: [build-pio, build-docker]
102130
if: ${{ github.event_name == 'release' }}
103131
steps:
104132
- name: Download firmware
@@ -115,56 +143,58 @@ jobs:
115143
release-docker:
116144
name: Release Docker
117145
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 }}
119148
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

Comments
 (0)