-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to actions-toolkit implementation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
- Loading branch information
CrazyMax
committed
Feb 24, 2023
1 parent
3da7dc6
commit af023e8
Showing
10 changed files
with
272 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import fs from 'fs'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
|
||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-login-action-')).split(path.sep).join(path.posix.sep); | ||
|
||
process.env = Object.assign({}, process.env, { | ||
TEMP: tmpDir, | ||
GITHUB_REPOSITORY: 'docker/login-action', | ||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep), | ||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep) | ||
}) as { | ||
[key: string]: string; | ||
}; | ||
|
||
module.exports = { | ||
clearMocks: true, | ||
moduleFileExtensions: ['js', 'ts'], | ||
setupFiles: ["dotenv/config"], | ||
testMatch: ['**/*.test.ts'], | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
moduleNameMapper: { | ||
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs' | ||
}, | ||
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'], | ||
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__tests__/'], | ||
verbose: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
import * as core from '@actions/core'; | ||
import * as actionsToolkit from '@docker/actions-toolkit'; | ||
|
||
import * as context from './context'; | ||
import * as docker from './docker'; | ||
import * as stateHelper from './state-helper'; | ||
|
||
export async function run(): Promise<void> { | ||
try { | ||
const input: context.Inputs = context.getInputs(); | ||
stateHelper.setRegistry(input.registry); | ||
stateHelper.setLogout(input.logout); | ||
await docker.login(input.registry, input.username, input.password, input.ecr); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
export async function main(): Promise<void> { | ||
const input: context.Inputs = context.getInputs(); | ||
stateHelper.setRegistry(input.registry); | ||
stateHelper.setLogout(input.logout); | ||
await docker.login(input.registry, input.username, input.password, input.ecr); | ||
} | ||
|
||
async function logout(): Promise<void> { | ||
async function post(): Promise<void> { | ||
if (!stateHelper.logout) { | ||
return; | ||
} | ||
await docker.logout(stateHelper.registry); | ||
} | ||
|
||
if (!stateHelper.IsPost) { | ||
run(); | ||
} else { | ||
logout(); | ||
} | ||
actionsToolkit.run(main, post); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"target": "es6", | ||
"module": "commonjs", | ||
"strict": true, | ||
"newLine": "lf", | ||
"outDir": "./lib", | ||
"rootDir": "./src", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitAny": false, | ||
"resolveJsonModule": true, | ||
"useUnknownInCatchVariables": false, | ||
}, | ||
"exclude": [ | ||
"./__tests__/**/*", | ||
"./lib/**/*", | ||
"node_modules", | ||
"**/*.test.ts", | ||
"jest.config.ts" | ||
] | ||
} |
Oops, something went wrong.