generated from actions/typescript-action
-
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.
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* The entrypoint for the action. | ||
*/ | ||
import { run } from './main.mjs' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run() |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as core from '@actions/core' | ||
import { wait } from './wait.mjs' | ||
import { createActionAuth } from '@octokit/auth-action' | ||
|
||
/** | ||
* The main function for the action. | ||
* @returns {Promise<void>} Resolves when the action is complete. | ||
*/ | ||
export async function run(): Promise<void> { | ||
try { | ||
const commit: string = core.getInput('commit') | ||
|
||
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true | ||
core.debug(`${commit} needs to be deployed ...`) | ||
|
||
// Log the current timestamp, wait, then log the new timestamp | ||
core.debug(new Date().toTimeString()) | ||
await wait(10000) | ||
core.debug(new Date().toTimeString()) | ||
|
||
const auth = createActionAuth() | ||
const authentication = await auth() | ||
|
||
console.log(authentication) | ||
|
||
// Set outputs for other workflow steps to use | ||
core.setOutput('time', new Date().toTimeString()) | ||
} catch (error) { | ||
// Fail the workflow run if an error occurs | ||
if (error instanceof Error) core.setFailed(error.message) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Wait for a number of milliseconds. | ||
* @param milliseconds The number of milliseconds to wait. | ||
* @returns {Promise<string>} Resolves with 'done!' after the wait is over. | ||
*/ | ||
export async function wait(milliseconds: number): Promise<string> { | ||
return new Promise(resolve => { | ||
if (isNaN(milliseconds)) { | ||
throw new Error('milliseconds not a number') | ||
} | ||
|
||
setTimeout(() => resolve('done!'), milliseconds) | ||
}) | ||
} |