Skip to content

Commit 52fc789

Browse files
committed
refactor: use ghcr as cache
1 parent c1d8430 commit 52fc789

File tree

1 file changed

+30
-63
lines changed

1 file changed

+30
-63
lines changed

.github/workflows/devel.yml

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@ on:
1414
- .github/workflows/*.yml
1515

1616
env:
17-
DOCKER_IMAGE: localhost:5000/github.com/joseluisq/rust-linux-darwin-builder
17+
DOCKER_IMAGE: ghcr.io/${{ github.repository }}
1818

1919
jobs:
2020
docker-amd64:
2121
name: Docker test (amd64)
2222
runs-on: ubuntu-22.04
23-
services:
24-
registry:
25-
image: registry:2
26-
ports:
27-
- 5000:5000
2823
steps:
2924
-
3025
name: Checkout
@@ -34,18 +29,20 @@ jobs:
3429
# https://github.com/actions/runner-images/issues/2840
3530
- name: Free disk space
3631
run: |
37-
sudo rm -rf /opt/ghc
32+
sudo du -sh /usr/share/dotnet
3833
sudo rm -rf /usr/share/dotnet
34+
- name: Free disk space
35+
run: |
36+
sudo du -sh /usr/local/lib/android
3937
sudo rm -rf /usr/local/lib/android
40-
sudo rm -rf "/usr/local/share/boost"
4138
-
42-
name: Cache Docker layers
43-
uses: actions/cache@v4
39+
name: Login to ghcr.io
40+
uses: docker/login-action@v3
41+
# if: github.ref == 'refs/heads/main'
4442
with:
45-
path: /tmp/.buildx-cache
46-
key: rust-linux-darwin-builder-amd64-buildx-${{ github.sha }}
47-
restore-keys: |
48-
rust-linux-darwin-builder-amd64-buildx-
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
4946
-
5047
name: Set up QEMU
5148
uses: docker/setup-qemu-action@v3
@@ -57,16 +54,8 @@ jobs:
5754
images: ${{ env.DOCKER_IMAGE }}
5855
flavor: |
5956
latest=false
60-
suffix=-amd64
6157
tags: |
62-
type=schedule
63-
type=ref,event=branch
64-
type=ref,event=pr
65-
type=semver,pattern={{version}}
66-
type=semver,pattern={{major}}.{{minor}}
67-
type=semver,pattern={{major}}
68-
type=sha
69-
type=raw,value=devel,suffix=-amd64
58+
type=raw,value=devel-amd64
7059
-
7160
name: Set up Docker Buildx
7261
uses: docker/setup-buildx-action@v3
@@ -79,21 +68,21 @@ jobs:
7968
context: .
8069
platforms: linux/amd64
8170
file: docker/amd64/base/Dockerfile
82-
load: true
8371
tags: ${{ steps.meta.outputs.tags }}
8472
labels: ${{ steps.meta.outputs.labels }}
8573
build-args: |
8674
VERSION=0.0.0
87-
push: ${{ github.event_name != 'pull_request' }}
88-
cache-from: type=local,src=/tmp/.buildx-cache
89-
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
75+
# push: ${{ github.ref == 'refs/heads/master' }}
76+
push: true
77+
cache-from: type=gha,scope=devel-amd64
78+
cache-to: type=gha,scope=devel-amd64,mode=max
9079
-
9180
name: Inspect image
9281
run: |
9382
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
9483
-
9584
name: Check manifest
96-
if: github.event_name != 'pull_request'
85+
# if: github.ref == 'refs/heads/master'
9786
run: |
9887
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
9988
-
@@ -108,14 +97,8 @@ jobs:
10897
cat /etc/debian_version
10998
uname -a
11099
make test-app
111-
-
112-
# Temp fix
113-
# https://github.com/docker/build-push-action/issues/252
114-
# https://github.com/moby/buildkit/issues/1896
115-
name: Move cache
116-
run: |
117-
rm -rf /tmp/.buildx-cache
118-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
100+
101+
## Docker AMD64 libs
119102

120103
-
121104
name: Cache Docker layers (libs)
@@ -133,49 +116,41 @@ jobs:
133116
images: ${{ env.DOCKER_IMAGE }}
134117
flavor: |
135118
latest=false
136-
suffix=-amd64-libs
137119
tags: |
138-
type=schedule
139-
type=ref,event=branch
140-
type=ref,event=pr
141-
type=semver,pattern={{version}}
142-
type=semver,pattern={{major}}.{{minor}}
143-
type=semver,pattern={{major}}
144-
type=sha
120+
type=raw,value=devel-libs-amd64
145121
-
146122
name: Set up Docker Buildx (libs)
147123
uses: docker/setup-buildx-action@v3
148124
with:
149125
driver-opts: network=host
150126
-
151-
name: Build and export to Docker client
127+
name: Build and export to Docker client (libs)
152128
uses: docker/build-push-action@v6
153129
with:
154130
context: .
155131
platforms: linux/amd64
156132
file: docker/amd64/libs/Dockerfile
157-
load: true
158133
tags: ${{ steps.meta2.outputs.tags }}
159134
labels: ${{ steps.meta2.outputs.labels }}
160135
build-args: |
161136
VERSION=0.0.0
162-
push: ${{ github.event_name != 'pull_request' }}
137+
# push: ${{ github.ref == 'refs/heads/master' }}
138+
push: true
163139
cache-from: |
164-
type=local,src=/tmp/.buildx-cache
165-
type=local,src=/tmp/.buildx-cache2
166-
cache-to: |
167-
type=local,dest=/tmp/.buildx-cache2-new,mode=max
140+
type=gha,scope=devel-libs-amd64
141+
type=gha,scope=devel-amd64
142+
cache-to: type=gha,scope=devel-libs-amd64,mode=max
168143
-
169-
name: Inspect image
144+
name: Inspect image (libs)
170145
run: |
171146
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}
172147
-
173-
name: Check manifest
174-
if: github.event_name != 'pull_request'
148+
name: Check manifest (libs)
149+
# if: github.ref == 'refs/heads/master'
175150
run: |
176151
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}
177152
-
178-
name: Run tests
153+
name: Run tests (libs)
179154
uses: addnab/docker-run-action@v3
180155
with:
181156
image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}"
@@ -188,14 +163,6 @@ jobs:
188163
make test-app
189164
make test-zlib
190165
make test-openssl
191-
-
192-
# Temp fix
193-
# https://github.com/docker/build-push-action/issues/252
194-
# https://github.com/moby/buildkit/issues/1896
195-
name: Move cache
196-
run: |
197-
rm -rf /tmp/.buildx-cache2
198-
mv /tmp/.buildx-cache2-new /tmp/.buildx-cache2
199166
200167
# docker-arm64:
201168
# name: Docker test (arm64)

0 commit comments

Comments
 (0)