diff --git a/package-lock.json b/package-lock.json index 3c4b3fa..ea70e0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5518,11 +5518,11 @@ "version": "1.0.0", "dependencies": { "@actions/core": "^1.10.0", - "@actions/exec": "^1.1.1", - "docker-cli-js": "^2.8.0" + "@actions/exec": "^1.1.1" } }, "push-module": { + "name": "slipstream-action-push-module", "version": "1.0.0", "dependencies": { "@actions/core": "^1.10.0", @@ -9198,8 +9198,7 @@ "version": "file:push-image", "requires": { "@actions/core": "^1.10.0", - "@actions/exec": "^1.1.1", - "docker-cli-js": "^2.8.0" + "@actions/exec": "^1.1.1" } }, "slipstream-action-push-module": { diff --git a/push-image/dist/index.js b/push-image/dist/index.js index 6ea3de6..47cc188 100644 --- a/push-image/dist/index.js +++ b/push-image/dist/index.js @@ -49329,16 +49329,16 @@ exports["default"] = _default; /***/ 29018: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +const core = __nccwpck_require__(75316); + const { execFileSync } = __nccwpck_require__(32081); function docker(command, ...args) { const out = execFileSync('docker', [command, ...args], { env: process.env }).toString('utf-8'); - /* eslint-disable no-console */ - console.log(`::group::> docker ${command} ${args.join(' ')}`); - console.log(out); - console.log('::endgroup::'); - /* eslint-enable no-console */ + core.group(`::group::> docker ${command} ${args.join(' ')}`, () => { + core.info(out); + }); return out; } @@ -49349,7 +49349,7 @@ function dockerJSON(command, ...args) { try { return JSON.parse(out); } catch (err) { - console.error(`:error::Failed to parse json output for "docker ${command} ${args.join(' ')}"`); + core.error(`Failed to parse json output for "docker ${command} ${args.join(' ')}"`); throw err; } } @@ -49414,7 +49414,7 @@ async function buildMetadata(input) { data.build = metadata.getBuildData(input.event); data.labels = metadata.getLabels(input.labels); data.release = input.release; - data.dockerInspect = dockerJSON('inspect', input.repo).object; + data.dockerInspect = dockerJSON('inspect', input.repo); return data; } @@ -55673,6 +55673,7 @@ async function run() { // when https://github.com/actions/toolkit/pull/725 is released release: (core.getInput('release') === 'true'), }); + await pushMetadata(metadataBucket, data); core.endGroup(); diff --git a/push-image/docker.js b/push-image/docker.js index 8e3bffa..9608d7c 100644 --- a/push-image/docker.js +++ b/push-image/docker.js @@ -1,13 +1,13 @@ +const core = require('@actions/core'); + const { execFileSync } = require('child_process'); function docker(command, ...args) { const out = execFileSync('docker', [command, ...args], { env: process.env }).toString('utf-8'); - /* eslint-disable no-console */ - console.log(`::group::> docker ${command} ${args.join(' ')}`); - console.log(out); - console.log('::endgroup::'); - /* eslint-enable no-console */ + core.group(`::group::> docker ${command} ${args.join(' ')}`, () => { + core.info(out); + }); return out; } @@ -18,7 +18,7 @@ function dockerJSON(command, ...args) { try { return JSON.parse(out); } catch (err) { - console.error(`:error::Failed to parse json output for "docker ${command} ${args.join(' ')}"`); + core.error(`Failed to parse json output for "docker ${command} ${args.join(' ')}"`); throw err; } } diff --git a/push-image/docker.test.js b/push-image/docker.test.js index 505d928..145bc4e 100644 --- a/push-image/docker.test.js +++ b/push-image/docker.test.js @@ -1,6 +1,7 @@ process.env.GITHUB_RUN_NUMBER = '2345'; const { execFileSync } = require('child_process'); +const { EOL } = require('os'); const { docker, dockerJSON } = require('./docker'); jest.mock('child_process', () => ({ @@ -13,8 +14,7 @@ beforeEach(() => { execFileSync.mockReset(); execFileSync.mockReturnValue(Buffer.alloc(0)); - jest.spyOn(global.console, 'error').mockImplementation(() => {}); - jest.spyOn(global.console, 'log').mockImplementation(() => {}); + jest.spyOn(process.stdout, 'write').mockImplementation(() => {}); process.env = { FOO: 'bar' }; }); @@ -42,8 +42,8 @@ describe('dockerJSON())', () => { execFileSync.mockReturnValue(Buffer.from('{')); expect(() => dockerJSON('docker', 'context', 'inspect')).toThrow(); - expect(global.console.error).toBeCalledWith( - ':error::Failed to parse json output for "docker docker context inspect"', + expect(process.stdout.write).toBeCalledWith( + `::error::Failed to parse json output for "docker docker context inspect"${EOL}`, ); }); }); diff --git a/push-image/index.js b/push-image/index.js index 7f33eaf..83980c9 100644 --- a/push-image/index.js +++ b/push-image/index.js @@ -60,6 +60,7 @@ async function run() { // when https://github.com/actions/toolkit/pull/725 is released release: (core.getInput('release') === 'true'), }); + await pushMetadata(metadataBucket, data); core.endGroup(); diff --git a/push-image/package.json b/push-image/package.json index 6a0a8d3..a527043 100644 --- a/push-image/package.json +++ b/push-image/package.json @@ -10,7 +10,6 @@ }, "dependencies": { "@actions/core": "^1.10.0", - "@actions/exec": "^1.1.1", - "docker-cli-js": "^2.8.0" + "@actions/exec": "^1.1.1" } } diff --git a/push-image/push.js b/push-image/push.js index 6c1294e..a962f9d 100644 --- a/push-image/push.js +++ b/push-image/push.js @@ -47,7 +47,7 @@ async function buildMetadata(input) { data.build = metadata.getBuildData(input.event); data.labels = metadata.getLabels(input.labels); data.release = input.release; - data.dockerInspect = dockerJSON('inspect', input.repo).object; + data.dockerInspect = dockerJSON('inspect', input.repo); return data; } diff --git a/push-image/push.test.js b/push-image/push.test.js index 9b75199..1127b3d 100644 --- a/push-image/push.test.js +++ b/push-image/push.test.js @@ -110,9 +110,7 @@ describe('getTags', () => { }); test('builds correct metadata', async () => { - docker.dockerJSON.mockReturnValue({ - object: [{ dummy: 'inspect' }], - }); + docker.dockerJSON.mockReturnValue([{ dummy: 'inspect' }]); const data = await buildMetadata({ event: { pull_request: {