From 9c8a0f90e80c41318bb3be73de12358c34499dac Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 12:06:18 -0400 Subject: [PATCH 01/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + action.yaml | 5 +++++ scripts/docker.js | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 7ba3c7d2..27ec36ee 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ jobs: | docker_file_name | no | The Dockerfile name, you can override for custom names (i.e. DevDockerfile) | Dockerfile | | docker_directory | no | Directory where the DockerFile is located. | . | | docker_build_args | no | Comma separated list of arguments that will be injected during the build, each on a new line. | - | +| docker_cache | no | Whether to use the Docker cache during the build. | true | ### Outputs diff --git a/action.yaml b/action.yaml index 52846444..ef603037 100644 --- a/action.yaml +++ b/action.yaml @@ -70,6 +70,10 @@ inputs: docker_build_args: description: "Comma separated list of arguments that will be injected during the build, each on a new line." required: false + docker_cache: + description: "Whether to use the Docker cache during the build." + required: false + default: "true" outputs: url: description: "The preview URL for the running application" @@ -121,6 +125,7 @@ runs: NAME: '${{ inputs.name }}' DOCKER_DIRECTORY: '${{ inputs.docker_directory }}' DOCKER_FILE_NAME: '${{ inputs.docker_file_name }}' + DOCKER_CACHE: '${{ inputs.docker_cache }}' GITHUB_SHA: '${{ github.sha }}' with: github-token: ${{ inputs.github_token }} diff --git a/scripts/docker.js b/scripts/docker.js index 793e3ade..dd70ada3 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -39,6 +39,7 @@ module.exports = async ({ github, context, exec, core, env }) => { const dockerDirectory = getInput(env, 'DOCKER_DIRECTORY'); const dockerFileName = getInput(env, 'DOCKER_FILE_NAME'); const githubSha = getInput(env, 'GITHUB_SHA'); + const dockerCache = (getInput(env, 'DOCKER_CACHE') ?? 'false') === 'true'; const fullImageName = `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`; @@ -59,6 +60,16 @@ module.exports = async ({ github, context, exec, core, env }) => { buildArgs.push(...['--build-arg', `${key}=${value}`]); }); + const cacheArgs = []; + if (dockerCache) { + cacheArgs.push( + '--cache-from', + `type=gha`, + '--cache-to', + 'type=gha,mode=max' + ); + } + await exec.exec('docker', [ 'build', ...buildArgs, From 81f5fb53130c2d43d63a9e4e2fd3fc30553a0607 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 12:18:04 -0400 Subject: [PATCH 02/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/docker.js b/scripts/docker.js index dd70ada3..0c62fb83 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -76,6 +76,7 @@ module.exports = async ({ github, context, exec, core, env }) => { ...tags, '--tag', `${fullImageName}:${githubSha}`, + ...cacheArgs, '--file', `${dockerDirectory}/${dockerFileName}`, `${dockerDirectory}` From a0a8e7f477356f5a06cf8a65eaa2480bcd735f68 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 12:22:08 -0400 Subject: [PATCH 03/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yaml | 3 +++ scripts/docker.js | 1 + 2 files changed, 4 insertions(+) diff --git a/action.yaml b/action.yaml index ef603037..011887d3 100644 --- a/action.yaml +++ b/action.yaml @@ -116,6 +116,9 @@ runs: shell: bash run: gcloud auth configure-docker us-docker.pkg.dev --quiet + - name: '🐳 Set up Docker Buildx' + uses: docker/setup-buildx-action@v3 + - name: '🐳 Build and Push Container' uses: actions/github-script@v7 env: diff --git a/scripts/docker.js b/scripts/docker.js index 0c62fb83..305f83a9 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -71,6 +71,7 @@ module.exports = async ({ github, context, exec, core, env }) => { } await exec.exec('docker', [ + 'buildx', 'build', ...buildArgs, ...tags, From 18be74c74077d4798d27fa7ac29b7eb35afe8771 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 12:46:05 -0400 Subject: [PATCH 04/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + scripts/docker.js | 21 +-- yarn.lock | 320 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 334 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index c4f55812..b4c9d6bf 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/scripts/docker.js b/scripts/docker.js index 305f83a9..44bca782 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -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'); @@ -42,6 +38,7 @@ module.exports = async ({ github, context, exec, core, env }) => { const dockerCache = (getInput(env, 'DOCKER_CACHE') ?? 'false') === 'true'; const fullImageName = `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`; + const branchName = context.ref.replace('refs/heads/', ''); const tags = []; if (dockerTags) { @@ -60,13 +57,21 @@ module.exports = async ({ github, context, exec, core, env }) => { buildArgs.push(...['--build-arg', `${key}=${value}`]); }); + // docker buildx build --push -t / \ + // --cache-to type=registry,ref=/: \ + // --cache-from type=registry,ref=/: \ + // --cache-from type=registry,ref=/:main . + + // @see https://docs.docker.com/build/cache/backends/#multiple-caches const cacheArgs = []; if (dockerCache) { cacheArgs.push( - '--cache-from', - `type=gha`, '--cache-to', - 'type=gha,mode=max' + `type=registry,ref=${fullImageName}:${branchName}`, + '--cache-from', + `type=registry,ref=${fullImageName}:${branchName}`, + '--cache-from', + `type=registry,ref=${fullImageName}:main`, ); } diff --git a/yarn.lock b/yarn.lock index 20d6a425..d482534d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,71 @@ __metadata: version: 8 cacheKey: 10c0 +"@actions/core@npm:^1.10.1, @actions/core@npm:^1.9.1": + version: 1.10.1 + resolution: "@actions/core@npm:1.10.1" + dependencies: + "@actions/http-client": "npm:^2.0.1" + uuid: "npm:^8.3.2" + checksum: 10c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832 + languageName: node + linkType: hard + +"@actions/exec@npm:^1.1.1": + version: 1.1.1 + resolution: "@actions/exec@npm:1.1.1" + dependencies: + "@actions/io": "npm:^1.0.1" + checksum: 10c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a + languageName: node + linkType: hard + +"@actions/github@npm:^6.0.0": + version: 6.0.0 + resolution: "@actions/github@npm:6.0.0" + dependencies: + "@actions/http-client": "npm:^2.2.0" + "@octokit/core": "npm:^5.0.1" + "@octokit/plugin-paginate-rest": "npm:^9.0.0" + "@octokit/plugin-rest-endpoint-methods": "npm:^10.0.0" + checksum: 10c0/6f86f564e6ec5873c69ff23bed308cef5f964dbdb559c5415c1ba479517bf18352713a2a757c27f8f67a3d675fdd78446cf142b27762489f697edf9c58e72378 + languageName: node + linkType: hard + +"@actions/glob@npm:^0.4.0": + version: 0.4.0 + resolution: "@actions/glob@npm:0.4.0" + dependencies: + "@actions/core": "npm:^1.9.1" + minimatch: "npm:^3.0.4" + checksum: 10c0/f50f029244b216676184ec00034508594cc750ed7efc2ebff490eb407352526424e1280cbf7fef95a75247f54a1732277ef6c007ce193aeca8430e7f4d356d33 + languageName: node + linkType: hard + +"@actions/http-client@npm:^2.0.1, @actions/http-client@npm:^2.2.0": + version: 2.2.1 + resolution: "@actions/http-client@npm:2.2.1" + dependencies: + tunnel: "npm:^0.0.6" + undici: "npm:^5.25.4" + checksum: 10c0/371771e68fcfe1383e59657eb5bc421aba5e1826f5e497efd826236b64fc1ff11f0bc91f936d7f1086f6bb3fd209736425a4d357b98fdfb7a8d054cbb84680e8 + languageName: node + linkType: hard + +"@actions/io@npm:^1.0.1, @actions/io@npm:^1.1.3": + version: 1.1.3 + resolution: "@actions/io@npm:1.1.3" + checksum: 10c0/5b8751918e5bf0bebd923ba917fb1c0e294401e7ff0037f32c92a4efa4215550df1f6633c63fd4efb2bdaae8711e69b9e36925857db1f38935ff62a5c92ec29e + languageName: node + linkType: hard + +"@fastify/busboy@npm:^2.0.0": + version: 2.1.1 + resolution: "@fastify/busboy@npm:2.1.1" + checksum: 10c0/6f8027a8cba7f8f7b736718b013f5a38c0476eea67034c94a0d3c375e2b114366ad4419e6a6fa7ffc2ef9c6d3e0435d76dd584a7a1cbac23962fda7650b579e3 + languageName: node + linkType: hard + "@google-cloud/run@npm:^1.0.2": version: 1.0.2 resolution: "@google-cloud/run@npm:1.0.2" @@ -45,6 +110,148 @@ __metadata: languageName: node linkType: hard +"@octokit/auth-token@npm:^4.0.0": + version: 4.0.0 + resolution: "@octokit/auth-token@npm:4.0.0" + checksum: 10c0/57acaa6c394c5abab2f74e8e1dcf4e7a16b236f713c77a54b8f08e2d14114de94b37946259e33ec2aab0566b26f724c2b71d2602352b59e541a9854897618f3c + languageName: node + linkType: hard + +"@octokit/core@npm:^5.0.1": + version: 5.2.0 + resolution: "@octokit/core@npm:5.2.0" + dependencies: + "@octokit/auth-token": "npm:^4.0.0" + "@octokit/graphql": "npm:^7.1.0" + "@octokit/request": "npm:^8.3.1" + "@octokit/request-error": "npm:^5.1.0" + "@octokit/types": "npm:^13.0.0" + before-after-hook: "npm:^2.2.0" + universal-user-agent: "npm:^6.0.0" + checksum: 10c0/9dc5cf55b335da382f340ef74c8009c06a1f7157b0530d3ff6cacf179887811352dcd405448e37849d73f17b28970b7817995be2260ce902dad52b91905542f0 + languageName: node + linkType: hard + +"@octokit/endpoint@npm:^9.0.1": + version: 9.0.5 + resolution: "@octokit/endpoint@npm:9.0.5" + dependencies: + "@octokit/types": "npm:^13.1.0" + universal-user-agent: "npm:^6.0.0" + checksum: 10c0/e9bbb2111abe691c146075abb1b6f724a9b77fa8bfefdaaa82b8ebad6c8790e949f2367bb0b79800fef93ad72807513333e83e8ffba389bc85215535f63534d9 + languageName: node + linkType: hard + +"@octokit/graphql@npm:^7.1.0": + version: 7.1.0 + resolution: "@octokit/graphql@npm:7.1.0" + dependencies: + "@octokit/request": "npm:^8.3.0" + "@octokit/types": "npm:^13.0.0" + universal-user-agent: "npm:^6.0.0" + checksum: 10c0/6d50a013d151f416fc837644e394e8b8872da7b17b181da119842ca569b0971e4dfacda55af6c329b51614e436945415dd5bd75eb3652055fdb754bbcd20d9d1 + languageName: node + linkType: hard + +"@octokit/openapi-types@npm:^20.0.0": + version: 20.0.0 + resolution: "@octokit/openapi-types@npm:20.0.0" + checksum: 10c0/5176dcc3b9d182ede3d446750cfa5cf31139624785a73fcf3511e3102a802b4d7cc45e999c27ed91d73fe8b7d718c8c406facb48688926921a71fe603b7db95d + languageName: node + linkType: hard + +"@octokit/openapi-types@npm:^22.2.0": + version: 22.2.0 + resolution: "@octokit/openapi-types@npm:22.2.0" + checksum: 10c0/a45bfc735611e836df0729f5922bbd5811d401052b972d1e3bc1278a2d2403e00f4552ce9d1f2793f77f167d212da559c5cb9f1b02c935114ad6d898779546ee + languageName: node + linkType: hard + +"@octokit/plugin-paginate-rest@npm:^9.0.0": + version: 9.2.1 + resolution: "@octokit/plugin-paginate-rest@npm:9.2.1" + dependencies: + "@octokit/types": "npm:^12.6.0" + peerDependencies: + "@octokit/core": 5 + checksum: 10c0/1dc55032a9e0c3e6440080a319975c9e4f189913fbc8870a48048d0c712473ea3d902ba247a37a46d45d502859b2728731a0d285107e4b0fa628d380f87163b4 + languageName: node + linkType: hard + +"@octokit/plugin-request-log@npm:^4.0.0": + version: 4.0.1 + resolution: "@octokit/plugin-request-log@npm:4.0.1" + peerDependencies: + "@octokit/core": 5 + checksum: 10c0/6f556f86258c5fbff9b1821075dc91137b7499f2ad0fd12391f0876064a6daa88abe1748336b2d483516505771d358aa15cb4bcdabc348a79e3d951fe9726798 + languageName: node + linkType: hard + +"@octokit/plugin-rest-endpoint-methods@npm:^10.0.0": + version: 10.4.1 + resolution: "@octokit/plugin-rest-endpoint-methods@npm:10.4.1" + dependencies: + "@octokit/types": "npm:^12.6.0" + peerDependencies: + "@octokit/core": 5 + checksum: 10c0/4b8f64c0f7fa12464546ad312a5289c2a799967e01e90e2c4923ec6e9604cf212dcb50d9795c9a688867f973c9c529c5950368564c560406c652bcd298f090af + languageName: node + linkType: hard + +"@octokit/plugin-retry@npm:^6.0.1": + version: 6.0.1 + resolution: "@octokit/plugin-retry@npm:6.0.1" + dependencies: + "@octokit/request-error": "npm:^5.0.0" + "@octokit/types": "npm:^12.0.0" + bottleneck: "npm:^2.15.3" + peerDependencies: + "@octokit/core": ">=5" + checksum: 10c0/721b5a7949e3defdec5f1b451850ab924162fd2712c9ab59a2aaaad5b9ed6ee2a9447fe82ec1f91086cf23aaaceb14ff4e74de67ba3c63c5029e59c67b50979c + languageName: node + linkType: hard + +"@octokit/request-error@npm:^5.0.0, @octokit/request-error@npm:^5.1.0": + version: 5.1.0 + resolution: "@octokit/request-error@npm:5.1.0" + dependencies: + "@octokit/types": "npm:^13.1.0" + deprecation: "npm:^2.0.0" + once: "npm:^1.4.0" + checksum: 10c0/61e688abce17dd020ea1e343470b9758f294bfe5432c5cb24bdb5b9b10f90ecec1ecaaa13b48df9288409e0da14252f6579a20f609af155bd61dc778718b7738 + languageName: node + linkType: hard + +"@octokit/request@npm:^8.3.0, @octokit/request@npm:^8.3.1": + version: 8.4.0 + resolution: "@octokit/request@npm:8.4.0" + dependencies: + "@octokit/endpoint": "npm:^9.0.1" + "@octokit/request-error": "npm:^5.1.0" + "@octokit/types": "npm:^13.1.0" + universal-user-agent: "npm:^6.0.0" + checksum: 10c0/b857782ac2ff5387e9cc502759de73ea642c498c97d06ad2ecd8a395e4b9532d9f3bc3fc460e0d3d0e8f0d43c917a90c493e43766d37782b3979d3afffbf1b4b + languageName: node + linkType: hard + +"@octokit/types@npm:^12.0.0, @octokit/types@npm:^12.6.0": + version: 12.6.0 + resolution: "@octokit/types@npm:12.6.0" + dependencies: + "@octokit/openapi-types": "npm:^20.0.0" + checksum: 10c0/0bea58bda46c93287f5a80a0e52bc60e7dc7136b8a38c3569d63d073fb9df4a56acdb9d9bdba9978f37c374a4a6e3e52886ef5b08cace048adb0012cacef942c + languageName: node + linkType: hard + +"@octokit/types@npm:^13.0.0, @octokit/types@npm:^13.1.0": + version: 13.5.0 + resolution: "@octokit/types@npm:13.5.0" + dependencies: + "@octokit/openapi-types": "npm:^22.2.0" + checksum: 10c0/355ebc6776ce23feace1b1be0927cdda758790fda83068109c4f27b354dcd43d0447d4dc24e5eafdb596465469ea1baed23f3fd63adfec508cc375ccd1dcb0a3 + languageName: node + linkType: hard + "@protobufjs/aspromise@npm:^1.1.1, @protobufjs/aspromise@npm:^1.1.2": version: 1.1.2 resolution: "@protobufjs/aspromise@npm:1.1.2" @@ -132,6 +339,23 @@ __metadata: languageName: node linkType: hard +"@types/github-script@github:actions/github-script": + version: 7.0.1 + resolution: "@types/github-script@https://github.com/actions/github-script.git#commit=60a0d83039c74a4aee543508d2ffcb1c3799cdea" + dependencies: + "@actions/core": "npm:^1.10.1" + "@actions/exec": "npm:^1.1.1" + "@actions/github": "npm:^6.0.0" + "@actions/glob": "npm:^0.4.0" + "@actions/io": "npm:^1.1.3" + "@octokit/core": "npm:^5.0.1" + "@octokit/plugin-request-log": "npm:^4.0.0" + "@octokit/plugin-retry": "npm:^6.0.1" + "@types/node": "npm:^20.9.0" + checksum: 10c0/d7fb9214d0f83866cadd1777e267198d7245740fde0444c99496f6663f109e68605196258f83753b801051ee5bf5fc00ce84af88a3f41467a29d9e993686affc + languageName: node + linkType: hard + "@types/long@npm:^4.0.0": version: 4.0.2 resolution: "@types/long@npm:4.0.2" @@ -148,6 +372,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.9.0": + version: 20.14.10 + resolution: "@types/node@npm:20.14.10" + dependencies: + undici-types: "npm:~5.26.4" + checksum: 10c0/0b06cff14365c2d0085dc16cc8cbea5c40ec09cfc1fea966be9eeecf35562760bfde8f88e86de6edfaf394501236e229d9c1084fad04fb4dec472ae245d8ae69 + languageName: node + linkType: hard + "@types/request@npm:^2.48.8": version: 2.48.12 resolution: "@types/request@npm:2.48.12" @@ -224,6 +457,13 @@ __metadata: languageName: node linkType: hard +"balanced-match@npm:^1.0.0": + version: 1.0.2 + resolution: "balanced-match@npm:1.0.2" + checksum: 10c0/9308baf0a7e4838a82bbfd11e01b1cb0f0cf2893bc1676c27c2a8c0e70cbae1c59120c3268517a8ae7fb6376b4639ef81ca22582611dbee4ed28df945134aaee + languageName: node + linkType: hard + "base64-js@npm:^1.3.0, base64-js@npm:^1.3.1": version: 1.5.1 resolution: "base64-js@npm:1.5.1" @@ -231,6 +471,13 @@ __metadata: languageName: node linkType: hard +"before-after-hook@npm:^2.2.0": + version: 2.2.3 + resolution: "before-after-hook@npm:2.2.3" + checksum: 10c0/0488c4ae12df758ca9d49b3bb27b47fd559677965c52cae7b335784724fb8bf96c42b6e5ba7d7afcbc31facb0e294c3ef717cc41c5bc2f7bd9e76f8b90acd31c + languageName: node + linkType: hard + "bignumber.js@npm:^9.0.0": version: 9.1.2 resolution: "bignumber.js@npm:9.1.2" @@ -238,6 +485,23 @@ __metadata: languageName: node linkType: hard +"bottleneck@npm:^2.15.3": + version: 2.19.5 + resolution: "bottleneck@npm:2.19.5" + checksum: 10c0/b0f72e45b2e0f56a21ba720183f16bef8e693452fb0495d997fa354e42904353a94bd8fd429868e6751bc85e54b6755190519eed5a0ae0a94a5185209ae7c6d0 + languageName: node + linkType: hard + +"brace-expansion@npm:^1.1.7": + version: 1.1.11 + resolution: "brace-expansion@npm:1.1.11" + dependencies: + balanced-match: "npm:^1.0.0" + concat-map: "npm:0.0.1" + checksum: 10c0/695a56cd058096a7cb71fb09d9d6a7070113c7be516699ed361317aca2ec169f618e28b8af352e02ab4233fb54eb0168460a40dc320bab0034b36ab59aaad668 + languageName: node + linkType: hard + "buffer-equal-constant-time@npm:1.0.1": version: 1.0.1 resolution: "buffer-equal-constant-time@npm:1.0.1" @@ -291,6 +555,13 @@ __metadata: languageName: node linkType: hard +"concat-map@npm:0.0.1": + version: 0.0.1 + resolution: "concat-map@npm:0.0.1" + checksum: 10c0/c996b1cfdf95b6c90fee4dae37e332c8b6eb7d106430c17d538034c0ad9a1630cb194d2ab37293b1bdd4d779494beee7786d586a50bd9376fd6f7bcc2bd4c98f + languageName: node + linkType: hard + "debug@npm:4, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" @@ -310,6 +581,13 @@ __metadata: languageName: node linkType: hard +"deprecation@npm:^2.0.0": + version: 2.3.1 + resolution: "deprecation@npm:2.3.1" + checksum: 10c0/23d688ba66b74d09b908c40a76179418acbeeb0bfdf218c8075c58ad8d0c315130cb91aa3dffb623aa3a411a3569ce56c6460de6c8d69071c17fe6dd2442f032 + languageName: node + linkType: hard + "duplexify@npm:^4.0.0": version: 4.1.2 resolution: "duplexify@npm:4.1.2" @@ -594,6 +872,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^3.0.4": + version: 3.1.2 + resolution: "minimatch@npm:3.1.2" + dependencies: + brace-expansion: "npm:^1.1.7" + checksum: 10c0/0262810a8fc2e72cca45d6fd86bd349eee435eb95ac6aa45c9ea2180e7ee875ef44c32b55b5973ceabe95ea12682f6e3725cbb63d7a2d1da3ae1163c8b210311 + languageName: node + linkType: hard + "ms@npm:2.1.2": version: 2.1.2 resolution: "ms@npm:2.1.2" @@ -681,6 +968,7 @@ __metadata: resolution: "previews@workspace:." dependencies: "@joggr/tempo": "npm:^0.6.0" + "@types/github-script": "github:actions/github-script" husky: "npm:^9.0.11" yaml: "npm:^2.3.4" languageName: unknown @@ -916,6 +1204,13 @@ __metadata: languageName: node linkType: hard +"tunnel@npm:^0.0.6": + version: 0.0.6 + resolution: "tunnel@npm:0.0.6" + checksum: 10c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75 + languageName: node + linkType: hard + "typescript@npm:^5.3.3": version: 5.3.3 resolution: "typescript@npm:5.3.3" @@ -943,6 +1238,22 @@ __metadata: languageName: node linkType: hard +"undici@npm:^5.25.4": + version: 5.28.4 + resolution: "undici@npm:5.28.4" + dependencies: + "@fastify/busboy": "npm:^2.0.0" + checksum: 10c0/08d0f2596553aa0a54ca6e8e9c7f45aef7d042c60918564e3a142d449eda165a80196f6ef19ea2ef2e6446959e293095d8e40af1236f0d67223b06afac5ecad7 + languageName: node + linkType: hard + +"universal-user-agent@npm:^6.0.0": + version: 6.0.1 + resolution: "universal-user-agent@npm:6.0.1" + checksum: 10c0/5c9c46ffe19a975e11e6443640ed4c9e0ce48fcc7203325757a8414ac49940ebb0f4667f2b1fa561489d1eb22cb2d05a0f7c82ec20c5cba42e58e188fb19b187 + languageName: node + linkType: hard + "util-deprecate@npm:^1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2" @@ -950,6 +1261,15 @@ __metadata: languageName: node linkType: hard +"uuid@npm:^8.3.2": + version: 8.3.2 + resolution: "uuid@npm:8.3.2" + bin: + uuid: dist/bin/uuid + checksum: 10c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54 + languageName: node + linkType: hard + "uuid@npm:^9.0.0, uuid@npm:^9.0.1": version: 9.0.1 resolution: "uuid@npm:9.0.1" From d6271244032f60491edea4103669f8e3c3cf6ee0 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 12:52:21 -0400 Subject: [PATCH 05/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/docker.js b/scripts/docker.js index 44bca782..80776386 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -66,10 +66,12 @@ module.exports = async ({ github, context, exec, core, env }) => { const cacheArgs = []; if (dockerCache) { cacheArgs.push( + // '--cache-to', + // `type=registry,ref=${fullImageName}:${branchName}`, + // '--cache-from', + // `type=registry,ref=${fullImageName}:${branchName}`, '--cache-to', - `type=registry,ref=${fullImageName}:${branchName}`, - '--cache-from', - `type=registry,ref=${fullImageName}:${branchName}`, + `type=registry,ref=${fullImageName}:main`, '--cache-from', `type=registry,ref=${fullImageName}:main`, ); From cb7b3f8fdb3b4830029be61a35de2bd1204c52d0 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 12:57:43 -0400 Subject: [PATCH 06/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 011887d3..e4f98d28 100644 --- a/action.yaml +++ b/action.yaml @@ -112,13 +112,13 @@ 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 - - name: '🐳 Set up Docker Buildx' - uses: docker/setup-buildx-action@v3 - - name: '🐳 Build and Push Container' uses: actions/github-script@v7 env: From e5f6b94404e0c9cf0b9edb1865d177a07ecf1be1 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:13:44 -0400 Subject: [PATCH 07/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yaml | 1 + scripts/docker.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/action.yaml b/action.yaml index e4f98d28..fe7f6e8d 100644 --- a/action.yaml +++ b/action.yaml @@ -130,6 +130,7 @@ runs: DOCKER_FILE_NAME: '${{ inputs.docker_file_name }}' DOCKER_CACHE: '${{ inputs.docker_cache }}' GITHUB_SHA: '${{ github.sha }}' + GITHUB_REF: '${{ github.ref }}' with: github-token: ${{ inputs.github_token }} script: | diff --git a/scripts/docker.js b/scripts/docker.js index 80776386..ea67a6e0 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -35,10 +35,11 @@ module.exports = async ({ github, context, exec, core, env }) => { const dockerDirectory = getInput(env, 'DOCKER_DIRECTORY'); const dockerFileName = getInput(env, 'DOCKER_FILE_NAME'); const githubSha = getInput(env, 'GITHUB_SHA'); + const githubRef = getInput(env, 'GITHUB_REF'); const dockerCache = (getInput(env, 'DOCKER_CACHE') ?? 'false') === 'true'; const fullImageName = `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`; - const branchName = context.ref.replace('refs/heads/', ''); + const branchName = githubRef.replace('refs/heads/', ''); const tags = []; if (dockerTags) { @@ -66,14 +67,14 @@ module.exports = async ({ github, context, exec, core, env }) => { const cacheArgs = []; if (dockerCache) { cacheArgs.push( - // '--cache-to', - // `type=registry,ref=${fullImageName}:${branchName}`, - // '--cache-from', - // `type=registry,ref=${fullImageName}:${branchName}`, - '--cache-to', - `type=registry,ref=${fullImageName}:main`, '--cache-from', - `type=registry,ref=${fullImageName}:main`, + `type=registry,ref=${fullImageName}:${branchName}`, + '--cache-to', + `type=registry,ref=${fullImageName}:${branchName}`, + // '--cache-from', + // `type=registry,ref=${fullImageName}:main`, + // '--cache-to', + // `type=registry,ref=${fullImageName}:main`, ); } @@ -91,7 +92,7 @@ module.exports = async ({ github, context, exec, core, env }) => { ]); await exec.exec('docker', [ 'push', - `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`, + fullImageName, '--all-tags' ]); } From e65799cf9d39a076631d0fc021dbbe0b8c7d7c6b Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:15:06 -0400 Subject: [PATCH 08/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index fe7f6e8d..e2ee3c13 100644 --- a/action.yaml +++ b/action.yaml @@ -130,7 +130,7 @@ runs: DOCKER_FILE_NAME: '${{ inputs.docker_file_name }}' DOCKER_CACHE: '${{ inputs.docker_cache }}' GITHUB_SHA: '${{ github.sha }}' - GITHUB_REF: '${{ github.ref }}' + GITHUB_REF: '${{ github.head_ref }}' with: github-token: ${{ inputs.github_token }} script: | From 0c05a6570df16f843e14b4cbde6609be0b33a162 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:20:01 -0400 Subject: [PATCH 09/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yaml | 2 +- scripts/docker.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index e2ee3c13..27b92b96 100644 --- a/action.yaml +++ b/action.yaml @@ -130,7 +130,7 @@ runs: DOCKER_FILE_NAME: '${{ inputs.docker_file_name }}' DOCKER_CACHE: '${{ inputs.docker_cache }}' GITHUB_SHA: '${{ github.sha }}' - GITHUB_REF: '${{ github.head_ref }}' + GITHUB_HEAD_REF: '${{ github.head_ref }}' with: github-token: ${{ inputs.github_token }} script: | diff --git a/scripts/docker.js b/scripts/docker.js index ea67a6e0..014a27ee 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -35,11 +35,11 @@ module.exports = async ({ github, context, exec, core, env }) => { const dockerDirectory = getInput(env, 'DOCKER_DIRECTORY'); const dockerFileName = getInput(env, 'DOCKER_FILE_NAME'); const githubSha = getInput(env, 'GITHUB_SHA'); - const githubRef = getInput(env, 'GITHUB_REF'); + const githubHeadRef = getInput(env, 'GITHUB_HEAD_REF'); const dockerCache = (getInput(env, 'DOCKER_CACHE') ?? 'false') === 'true'; const fullImageName = `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`; - const branchName = githubRef.replace('refs/heads/', ''); + const branchName = githubHeadRef.replace('refs/heads/', ''); const tags = []; if (dockerTags) { From 5480e5f4f9085e205d412a7df8ef358195ca69a2 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:23:48 -0400 Subject: [PATCH 10/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/docker.js b/scripts/docker.js index 014a27ee..d31a2f31 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -68,9 +68,9 @@ module.exports = async ({ github, context, exec, core, env }) => { if (dockerCache) { cacheArgs.push( '--cache-from', - `type=registry,ref=${fullImageName}:${branchName}`, + `type=registry,ref="${fullImageName}:${branchName}"`, '--cache-to', - `type=registry,ref=${fullImageName}:${branchName}`, + `type=registry,ref="${fullImageName}:${branchName}"`, // '--cache-from', // `type=registry,ref=${fullImageName}:main`, // '--cache-to', From a09c8301929698dc739a3778a9b4537d14a50169 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:28:45 -0400 Subject: [PATCH 11/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/docker.js b/scripts/docker.js index d31a2f31..80ad3e7a 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -68,9 +68,9 @@ module.exports = async ({ github, context, exec, core, env }) => { if (dockerCache) { cacheArgs.push( '--cache-from', - `type=registry,ref="${fullImageName}:${branchName}"`, + `"type=registry,ref=${fullImageName}:${branchName}"`, '--cache-to', - `type=registry,ref="${fullImageName}:${branchName}"`, + `"type=registry,ref="${fullImageName}:${branchName}"`, // '--cache-from', // `type=registry,ref=${fullImageName}:main`, // '--cache-to', From c51afdb3722943729ea3c96a44a28992ec2cde10 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:30:35 -0400 Subject: [PATCH 12/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker.js b/scripts/docker.js index 80ad3e7a..07003c5d 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -70,7 +70,7 @@ module.exports = async ({ github, context, exec, core, env }) => { '--cache-from', `"type=registry,ref=${fullImageName}:${branchName}"`, '--cache-to', - `"type=registry,ref="${fullImageName}:${branchName}"`, + `"type=registry,ref=${fullImageName}:${branchName}"`, // '--cache-from', // `type=registry,ref=${fullImageName}:main`, // '--cache-to', From a93adef61bf80095f778b94e32a7641b63dcc410 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:36:08 -0400 Subject: [PATCH 13/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/docker.js b/scripts/docker.js index 07003c5d..2bbe6dc8 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -64,9 +64,10 @@ module.exports = async ({ github, context, exec, core, env }) => { // --cache-from type=registry,ref=/:main . // @see https://docs.docker.com/build/cache/backends/#multiple-caches - const cacheArgs = []; + const buildCache = []; if (dockerCache) { - cacheArgs.push( + buildCache.push( + '--push', '--cache-from', `"type=registry,ref=${fullImageName}:${branchName}"`, '--cache-to', @@ -85,11 +86,12 @@ module.exports = async ({ github, context, exec, core, env }) => { ...tags, '--tag', `${fullImageName}:${githubSha}`, - ...cacheArgs, + ...buildCache, '--file', `${dockerDirectory}/${dockerFileName}`, `${dockerDirectory}` ]); + await exec.exec('docker', [ 'push', fullImageName, From bc2cde36bec89cc10eeef605d26059f874d5ef20 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 13:58:35 -0400 Subject: [PATCH 14/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/docker.js b/scripts/docker.js index 2bbe6dc8..bbb6459d 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -63,15 +63,23 @@ module.exports = async ({ github, context, exec, core, env }) => { // --cache-from type=registry,ref=/: \ // --cache-from type=registry,ref=/:main . + // --cache-to type=gha[,parameters...] \ + // --cache-from type=gha[,parameters...] . + // @see https://docs.docker.com/build/cache/backends/#multiple-caches const buildCache = []; if (dockerCache) { buildCache.push( '--push', - '--cache-from', - `"type=registry,ref=${fullImageName}:${branchName}"`, '--cache-to', - `"type=registry,ref=${fullImageName}:${branchName}"`, + 'type=gha,mode=max', + '--cache-from', + 'type=gha,mode=max', + + // '--cache-from', + // `"type=registry,ref=${fullImageName}:${branchName}"`, + // '--cache-to', + // `"type=registry,ref=${fullImageName}:${branchName}"`, // '--cache-from', // `type=registry,ref=${fullImageName}:main`, // '--cache-to', From 3421d36bf8b694711809214ce0028dd7068e20a7 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 14:14:08 -0400 Subject: [PATCH 15/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- action.yaml | 3 +-- scripts/docker.js | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 27ec36ee..969a6b1e 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ jobs: | docker_file_name | no | The Dockerfile name, you can override for custom names (i.e. DevDockerfile) | Dockerfile | | docker_directory | no | Directory where the DockerFile is located. | . | | docker_build_args | no | Comma separated list of arguments that will be injected during the build, each on a new line. | - | -| docker_cache | no | Whether to use the Docker cache during the build. | true | +| docker_cache | no | The type of cache to use during the build, one of 'gha' or 'registry' (not-supported). | true | ### Outputs diff --git a/action.yaml b/action.yaml index 27b92b96..a56a1cf6 100644 --- a/action.yaml +++ b/action.yaml @@ -71,7 +71,7 @@ inputs: description: "Comma separated list of arguments that will be injected during the build, each on a new line." required: false docker_cache: - description: "Whether to use the Docker cache during the build." + description: "The type of cache to use during the build, one of 'gha' or 'registry' (not-supported)." required: false default: "true" outputs: @@ -130,7 +130,6 @@ runs: DOCKER_FILE_NAME: '${{ inputs.docker_file_name }}' DOCKER_CACHE: '${{ inputs.docker_cache }}' GITHUB_SHA: '${{ github.sha }}' - GITHUB_HEAD_REF: '${{ github.head_ref }}' with: github-token: ${{ inputs.github_token }} script: | diff --git a/scripts/docker.js b/scripts/docker.js index bbb6459d..f3a4da22 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -35,11 +35,9 @@ module.exports = async ({ github, context, exec, core, env }) => { const dockerDirectory = getInput(env, 'DOCKER_DIRECTORY'); const dockerFileName = getInput(env, 'DOCKER_FILE_NAME'); const githubSha = getInput(env, 'GITHUB_SHA'); - const githubHeadRef = getInput(env, 'GITHUB_HEAD_REF'); - const dockerCache = (getInput(env, 'DOCKER_CACHE') ?? 'false') === 'true'; + const dockerCache = getInput(env, 'DOCKER_CACHE') === 'gha'; const fullImageName = `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`; - const branchName = githubHeadRef.replace('refs/heads/', ''); const tags = []; if (dockerTags) { @@ -71,9 +69,9 @@ module.exports = async ({ github, context, exec, core, env }) => { if (dockerCache) { buildCache.push( '--push', - '--cache-to', - 'type=gha,mode=max', '--cache-from', + 'type=gha', + '--cache-to', 'type=gha,mode=max', // '--cache-from', @@ -90,19 +88,21 @@ module.exports = async ({ github, context, exec, core, env }) => { await exec.exec('docker', [ 'buildx', 'build', + ...buildCache, ...buildArgs, ...tags, '--tag', `${fullImageName}:${githubSha}`, - ...buildCache, - '--file', + '--file', `${dockerDirectory}/${dockerFileName}`, `${dockerDirectory}` ]); - await exec.exec('docker', [ - 'push', - fullImageName, - '--all-tags' - ]); + if (!dockerCache) { + await exec.exec('docker', [ + 'push', + fullImageName, + '--all-tags' + ]); + } } From daf69cae8e6717db9dd09900e2233a8d59dd5fee Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 17:08:14 -0400 Subject: [PATCH 16/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- action.yaml | 2 +- scripts/docker.js | 43 +++++-------------------------------------- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 969a6b1e..533b21fc 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ jobs: | docker_file_name | no | The Dockerfile name, you can override for custom names (i.e. DevDockerfile) | Dockerfile | | docker_directory | no | Directory where the DockerFile is located. | . | | docker_build_args | no | Comma separated list of arguments that will be injected during the build, each on a new line. | - | -| docker_cache | no | The type of cache to use during the build, one of 'gha' or 'registry' (not-supported). | true | +| docker_cache | no | The type of cache to use during the build, one of 'gha' or 'registry' (not-supported). | gha | ### Outputs diff --git a/action.yaml b/action.yaml index a56a1cf6..80d2d6d4 100644 --- a/action.yaml +++ b/action.yaml @@ -73,7 +73,7 @@ inputs: docker_cache: description: "The type of cache to use during the build, one of 'gha' or 'registry' (not-supported)." required: false - default: "true" + default: "gha" outputs: url: description: "The preview URL for the running application" diff --git a/scripts/docker.js b/scripts/docker.js index f3a4da22..b726a068 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -56,39 +56,14 @@ module.exports = async ({ github, context, exec, core, env }) => { buildArgs.push(...['--build-arg', `${key}=${value}`]); }); - // docker buildx build --push -t / \ - // --cache-to type=registry,ref=/: \ - // --cache-from type=registry,ref=/: \ - // --cache-from type=registry,ref=/:main . - - // --cache-to type=gha[,parameters...] \ - // --cache-from type=gha[,parameters...] . - - // @see https://docs.docker.com/build/cache/backends/#multiple-caches - const buildCache = []; - if (dockerCache) { - buildCache.push( - '--push', - '--cache-from', - 'type=gha', - '--cache-to', - 'type=gha,mode=max', - - // '--cache-from', - // `"type=registry,ref=${fullImageName}:${branchName}"`, - // '--cache-to', - // `"type=registry,ref=${fullImageName}:${branchName}"`, - // '--cache-from', - // `type=registry,ref=${fullImageName}:main`, - // '--cache-to', - // `type=registry,ref=${fullImageName}:main`, - ); - } - await exec.exec('docker', [ 'buildx', 'build', - ...buildCache, + '--push', + '--cache-from', + 'type=gha', + '--cache-to', + 'type=gha,mode=max', ...buildArgs, ...tags, '--tag', @@ -97,12 +72,4 @@ module.exports = async ({ github, context, exec, core, env }) => { `${dockerDirectory}/${dockerFileName}`, `${dockerDirectory}` ]); - - if (!dockerCache) { - await exec.exec('docker', [ - 'push', - fullImageName, - '--all-tags' - ]); - } } From 8e01ff883a1d307b5e58a629c164574fc43ef08f Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 17:12:56 -0400 Subject: [PATCH 17/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/docker.js b/scripts/docker.js index b726a068..b4387632 100644 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -35,7 +35,6 @@ module.exports = async ({ github, context, exec, core, env }) => { const dockerDirectory = getInput(env, 'DOCKER_DIRECTORY'); const dockerFileName = getInput(env, 'DOCKER_FILE_NAME'); const githubSha = getInput(env, 'GITHUB_SHA'); - const dockerCache = getInput(env, 'DOCKER_CACHE') === 'gha'; const fullImageName = `us-docker.pkg.dev/${gcpProjectId}/${gcpArtifactRepository}/${name}`; From 4bee9ef09a0d856c58856ca589cfeb2793fbbed5 Mon Sep 17 00:00:00 2001 From: Zac Rosenbauer Date: Fri, 12 Jul 2024 17:18:04 -0400 Subject: [PATCH 18/18] =?UTF-8?q?=F0=9F=92=BD=20incremental=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - action.yaml | 5 ----- 2 files changed, 6 deletions(-) diff --git a/README.md b/README.md index 533b21fc..7ba3c7d2 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,6 @@ jobs: | docker_file_name | no | The Dockerfile name, you can override for custom names (i.e. DevDockerfile) | Dockerfile | | docker_directory | no | Directory where the DockerFile is located. | . | | docker_build_args | no | Comma separated list of arguments that will be injected during the build, each on a new line. | - | -| docker_cache | no | The type of cache to use during the build, one of 'gha' or 'registry' (not-supported). | gha | ### Outputs diff --git a/action.yaml b/action.yaml index 80d2d6d4..c14ab00a 100644 --- a/action.yaml +++ b/action.yaml @@ -70,10 +70,6 @@ inputs: docker_build_args: description: "Comma separated list of arguments that will be injected during the build, each on a new line." required: false - docker_cache: - description: "The type of cache to use during the build, one of 'gha' or 'registry' (not-supported)." - required: false - default: "gha" outputs: url: description: "The preview URL for the running application" @@ -128,7 +124,6 @@ runs: NAME: '${{ inputs.name }}' DOCKER_DIRECTORY: '${{ inputs.docker_directory }}' DOCKER_FILE_NAME: '${{ inputs.docker_file_name }}' - DOCKER_CACHE: '${{ inputs.docker_cache }}' GITHUB_SHA: '${{ github.sha }}' with: github-token: ${{ inputs.github_token }}