Skip to content

Commit bd8290f

Browse files
authored
Merge pull request #2037 from gtardif/cache_image_CI
Add cache to building hub image in CI
2 parents 231520e + b401874 commit bd8290f

1 file changed

Lines changed: 12 additions & 28 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
fail-on-error: true
4040
pyflakes: false
4141

42-
test:
42+
build-and-test:
4343
runs-on: ubuntu-latest
4444
steps:
4545
- name: Checkout
@@ -56,6 +56,12 @@ jobs:
5656
with:
5757
version: 3.x
5858

59+
- name: Create bin directory
60+
run: mkdir -p "$HOME/bin"
61+
62+
- name: Build
63+
run: task build
64+
5965
- name: Run tests
6066
run: |
6167
task test
@@ -79,32 +85,8 @@ jobs:
7985
- name: Check licenses
8086
run: go-licenses check . --allowed_licenses=Apache-2.0,MIT,BSD-3-Clause,BSD-2-Clause --ignore modernc.org/mathutil
8187

82-
build:
83-
needs: [lint, test, license-check]
84-
runs-on: ubuntu-latest
85-
steps:
86-
- name: Checkout
87-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
88-
89-
- name: Set up Go
90-
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
91-
with:
92-
go-version: "1.26.0"
93-
cache: true
94-
95-
- name: Install Task
96-
uses: go-task/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 # v1.0.0
97-
with:
98-
version: 3.x
99-
100-
- name: Create bin directory
101-
run: mkdir -p "$HOME/bin"
102-
103-
- name: Build
104-
run: task build
105-
10688
build-image:
107-
needs: [lint, test, license-check]
89+
needs: [lint, build-and-test, license-check]
10890
runs-on: ubuntu-latest
10991
steps:
11092
- name: Checkout
@@ -142,5 +124,7 @@ jobs:
142124
tags: ${{ steps.meta.outputs.tags }}
143125
labels: ${{ steps.meta.outputs.labels }}
144126
build-args: |
145-
GIT_TAG=${{ github.ref_name }}
146-
GIT_COMMIT=${{ github.sha }}
127+
GIT_TAG=${{ github.event_name == 'pull_request' && 'pr' || github.ref_name }}
128+
GIT_COMMIT=${{ github.event_name == 'pull_request' && 'dev' || github.sha }}
129+
cache-from: type=gha,scope=buildx
130+
cache-to: type=gha,mode=max,scope=buildx

0 commit comments

Comments
 (0)