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

🧰 chore: Faster Builds using GHA Cache #377

Merged
merged 21 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ runs:
with:
project_id: ${{ inputs.gcp_project_id }}

- name: '🐳 Set up Docker Buildx'
uses: docker/setup-buildx-action@v3

- name: '🐳 Authorize Docker push'
shell: bash
run: gcloud auth configure-docker us-docker.pkg.dev --quiet
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
],
"devDependencies": {
"@joggr/tempo": "^0.6.0",
"@types/github-script": "github:actions/github-script",
"husky": "^9.0.11",
"yaml": "^2.3.4"
},
Expand Down
19 changes: 8 additions & 11 deletions scripts/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ function getMultilineInput(env, name) {
/**
* Build & Push Docker Image
*
* @param {object} payload
* @param {object} payload.context
* @param {object} payload.core
* @param {object} payload.github
* @param {object} payload.exec
* @param {import('@types/github-script').AsyncFunctionArguments} payload
*/
module.exports = async ({ github, context, exec, core, env }) => {
const dockerBuildArgs = getMultilineInput(env, 'DOCKER_BUILD_ARGS');
Expand Down Expand Up @@ -60,18 +56,19 @@ module.exports = async ({ github, context, exec, core, env }) => {
});

await exec.exec('docker', [
'buildx',
'build',
'--push',
'--cache-from',
'type=gha',
'--cache-to',
'type=gha,mode=max',
...buildArgs,
...tags,
'--tag',
`${fullImageName}:${githubSha}`,
'--file',
'--file',
`${dockerDirectory}/${dockerFileName}`,
`${dockerDirectory}`
]);
await exec.exec('docker', [
'push',
`us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`,
'--all-tags'
]);
}
Loading