-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors action sourcecode to typescript
- Loading branch information
1 parent
fa45e8b
commit 6625f10
Showing
13 changed files
with
820 additions
and
6,700 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
index.guard | ||
dist | ||
node_modules |
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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as core from '@actions/core' | ||
import { Octokit } from '@octokit/rest'; | ||
|
||
type Release = { | ||
html_url: string | ||
draft: boolean | ||
prerelease: boolean | ||
tag_name: string | ||
} | ||
|
||
async function getReleases(): Promise<Release[]> { | ||
const octokit = new Octokit({auth: core.getInput('token') || process.env.GITHUB_TOKEN}) | ||
const [ owner, repo ] = process.env.GITHUB_ACTION_REPOSITORY?.split('/') ?? [undefined, undefined] | ||
if (!owner || !repo) { | ||
core.setFailed('Failed to determine owner and repository for this action.') | ||
return [] | ||
} | ||
return octokit.rest.repos.listReleases({ owner, repo }) | ||
.then(({ data }) => data) | ||
.then((json) => json.map((release): Release => ({ | ||
html_url: release.html_url, | ||
draft: release.draft, | ||
prerelease: release.prerelease, | ||
tag_name: release.tag_name, | ||
}))) | ||
} | ||
|
||
core.setFailed('Must use a tagged release of this action! See summary for more details.') | ||
getReleases() | ||
.then((releases) => { | ||
const latestStable = releases.find((release: Release) => !release.prerelease && !release.draft)?.tag_name ?? 'v1' | ||
return core.summary | ||
.addHeading('🏷️ Only tagged releases of this action can be used in workflows', 3) | ||
.addRaw('Only tagged releases of this action can be used, e.g.\n', true) | ||
.addRaw('```yaml', true) | ||
.addRaw(`- uses: ${process.env.GITHUB_ACTION_REPOSITORY}@${latestStable}`, true) | ||
.addRaw('```\n', true) | ||
.addRaw('----\nThe following releases are available:', true) | ||
.addRaw(releases.map((release) => `* [${release.tag_name}](${release.html_url})`).join('\n'), true) | ||
.write({overwrite: true}) | ||
}) | ||
.catch(() => { | ||
core.notice('Failed to fetch releases from GitHub.') | ||
}) |
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
Oops, something went wrong.