Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 84547c6

Browse files
authored
🧰 chore: Faster Builds using GHA Cache (#377)
1 parent 3fa56c2 commit 84547c6

File tree

4 files changed

+332
-11
lines changed

4 files changed

+332
-11
lines changed

action.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ runs:
108108
with:
109109
project_id: ${{ inputs.gcp_project_id }}
110110

111+
- name: '🐳 Set up Docker Buildx'
112+
uses: docker/setup-buildx-action@v3
113+
111114
- name: '🐳 Authorize Docker push'
112115
shell: bash
113116
run: gcloud auth configure-docker us-docker.pkg.dev --quiet

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
],
88
"devDependencies": {
99
"@joggr/tempo": "^0.6.0",
10+
"@types/github-script": "github:actions/github-script",
1011
"husky": "^9.0.11",
1112
"yaml": "^2.3.4"
1213
},

scripts/docker.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ function getMultilineInput(env, name) {
2424
/**
2525
* Build & Push Docker Image
2626
*
27-
* @param {object} payload
28-
* @param {object} payload.context
29-
* @param {object} payload.core
30-
* @param {object} payload.github
31-
* @param {object} payload.exec
27+
* @param {import('@types/github-script').AsyncFunctionArguments} payload
3228
*/
3329
module.exports = async ({ github, context, exec, core, env }) => {
3430
const dockerBuildArgs = getMultilineInput(env, 'DOCKER_BUILD_ARGS');
@@ -60,18 +56,19 @@ module.exports = async ({ github, context, exec, core, env }) => {
6056
});
6157

6258
await exec.exec('docker', [
59+
'buildx',
6360
'build',
61+
'--push',
62+
'--cache-from',
63+
'type=gha',
64+
'--cache-to',
65+
'type=gha,mode=max',
6466
...buildArgs,
6567
...tags,
6668
'--tag',
6769
`${fullImageName}:${githubSha}`,
68-
'--file',
70+
'--file',
6971
`${dockerDirectory}/${dockerFileName}`,
7072
`${dockerDirectory}`
7173
]);
72-
await exec.exec('docker', [
73-
'push',
74-
`us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`,
75-
'--all-tags'
76-
]);
7774
}

0 commit comments

Comments
 (0)