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
8 changed files
with
111 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,14 +1,24 @@ | ||
/** | ||
* 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') | ||
} | ||
import { getLock } from './main' | ||
import * as core from '@actions/core' | ||
|
||
setTimeout(() => resolve('done!'), milliseconds) | ||
export async function checkOrWait(): Promise<string> { | ||
return new Promise(async (resolve, reject) => { | ||
await check(resolve, reject) | ||
}) | ||
} | ||
|
||
async function check(resolve: any, reject: any) { | ||
const lock = await getLock() | ||
|
||
if (!lock) { | ||
resolve('Done!') | ||
} else { | ||
if (lock.purpose === 'manual deployment lock') { | ||
// Some other deployment is running, so we wait | ||
core.setFailed('Manual deployment lock active!') | ||
reject('Locked') | ||
} | ||
} | ||
|
||
setTimeout(check, 20000) | ||
} |