mirror of
https://github.com/docker/setup-docker-action.git
synced 2025-04-19 15:20:02 +02:00
tear down post step
This commit is contained in:
parent
611b62c8d7
commit
f2c84c46da
@ -14,3 +14,4 @@ inputs:
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
post: 'dist/index.js'
|
||||
|
@ -28,7 +28,8 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@docker/actions-toolkit": "link:../../docker_org/actions/docker-actions-toolkit"
|
||||
"@docker/actions-toolkit": "link:../../docker_org/actions/docker-actions-toolkit",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.26",
|
||||
|
22
src/main.ts
22
src/main.ts
@ -1,17 +1,21 @@
|
||||
import * as context from './context';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import * as uuid from 'uuid';
|
||||
import * as core from '@actions/core';
|
||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||
|
||||
import {Install} from '../../../docker_org/actions/docker-actions-toolkit/lib/docker/install';
|
||||
import {Context} from '../../../docker_org/actions/docker-actions-toolkit/lib/context';
|
||||
import {Docker} from '../../../docker_org/actions/docker-actions-toolkit/lib/docker/docker';
|
||||
|
||||
import * as context from './context';
|
||||
import * as stateHelper from './state-helper';
|
||||
|
||||
actionsToolkit.run(
|
||||
// main
|
||||
async () => {
|
||||
const input: context.Inputs = context.getInputs();
|
||||
const install = new Install();
|
||||
|
||||
const install = new Install();
|
||||
let toolDir;
|
||||
if (!(await Docker.isAvailable()) || input.version) {
|
||||
await core.group(`Download docker`, async () => {
|
||||
@ -19,12 +23,22 @@ actionsToolkit.run(
|
||||
});
|
||||
}
|
||||
if (toolDir) {
|
||||
await install.install(toolDir, Context.tmpDir(), input.version);
|
||||
const runDir = path.join(os.homedir(), `setup-docker-action-${uuid.v4()}`);
|
||||
stateHelper.setRunDir(runDir);
|
||||
await install.install(toolDir, runDir, input.version);
|
||||
}
|
||||
|
||||
await core.group(`Docker info`, async () => {
|
||||
await Docker.printVersion();
|
||||
await Docker.printInfo();
|
||||
});
|
||||
},
|
||||
// post
|
||||
async () => {
|
||||
if (stateHelper.runDir.length == 0) {
|
||||
return;
|
||||
}
|
||||
const install = new Install();
|
||||
await install.tearDown(stateHelper.runDir);
|
||||
}
|
||||
);
|
||||
|
7
src/state-helper.ts
Normal file
7
src/state-helper.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export const runDir = process.env['STATE_rundir'] || '';
|
||||
|
||||
export function setRunDir(runDir: string) {
|
||||
core.saveState('rundir', runDir);
|
||||
}
|
@ -3204,6 +3204,11 @@ uuid@^8.3.2:
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
uuid@^9.0.0:
|
||||
version "9.0.0"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
|
||||
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==
|
||||
|
||||
v8-compile-cache-lib@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8"
|
||||
|
Loading…
x
Reference in New Issue
Block a user