This repository has been archived by the owner on Jul 31, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shortlinks action (task 2 in #789)
- Loading branch information
Showing
21 changed files
with
927 additions
and
290 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# .actions/ folder | ||
> This is where any miscellaneous GitHub actions are ran with Nino. |
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
{ | ||
"name": "@nino/actions-suite", | ||
"description": "Miscellaneous GitHub actions tailored for Nino's repository", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"author": "Noel <[email protected]>", | ||
"private": true, | ||
"scripts": { | ||
"build:shortlinks": "ncc build src/shortlinks.ts -o build -m -C --license LICENSE" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "1.5.0", | ||
"@actions/github": "5.0.0", | ||
"@augu/utils": "1.5.3", | ||
"@octokit/core": "3.5.1" | ||
}, | ||
"devDependencies": { | ||
"@augu/tsconfig": "1.1.1", | ||
"@vercel/ncc": "0.31.1", | ||
"typescript": "4.4.3" | ||
} | ||
} |
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,83 @@ | ||
/** | ||
* Copyright (c) 2019-2021 Nino | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import * as github from '@actions/github'; | ||
import * as core from '@actions/core'; | ||
import { exec } from 'child_process'; | ||
import { join } from 'path'; | ||
|
||
const overwriteLogger = () => { | ||
const mapped = { | ||
info: core.info, | ||
debug: core.debug, | ||
warn: core.warning, | ||
error: core.error, | ||
}; | ||
|
||
for (const key of ['info', 'debug', 'warn', 'error']) { | ||
const mappedFn = mapped[key]; | ||
core[key] = (message: string) => { | ||
const date = new Date(); | ||
const ampm = date.getHours() >= 12 ? 'PM' : 'AM'; | ||
|
||
return mappedFn( | ||
`[${`0${date.getHours()}`.slice(-2)}:${`0${date.getMinutes()}`.slice(-2)}:${`0${date.getSeconds()}`.slice( | ||
-2 | ||
)} ${ampm}] ${message}` | ||
); | ||
}; | ||
} | ||
}; | ||
|
||
const exitIfCodeExists = () => { | ||
if (process.exitCode !== undefined) process.exit(process.exitCode); | ||
}; | ||
|
||
const main = () => { | ||
overwriteLogger(); | ||
|
||
if (github.context.eventName === 'push' && github.context.payload?.head_commit) { | ||
if (github.context.payload.head_commit.message.includes('[skip action]')) { | ||
core.info('Told to skip the action, not running.'); | ||
process.exitCode = 1; | ||
} | ||
} | ||
|
||
exitIfCodeExists(); | ||
core.info('Now running `shortlinks` action...'); | ||
|
||
const proc = exec('node scripts/shortlinks.js', { | ||
cwd: join(__dirname, '..', '..'), | ||
}); | ||
|
||
proc.stdout?.on('data', (chunk) => core.info(`\n${chunk}`)); | ||
proc.stderr?.on('data', (chunk) => core.warning(`\n${chunk}`)); | ||
|
||
return new Promise((resolve, reject) => | ||
proc.on('exit', (code, signal) => { | ||
core.info(`Script exited with code ${code}${signal ? `, with signal ${signal}` : ''}.`); | ||
return code === 0 ? resolve(void 0) : reject(); | ||
}) | ||
); | ||
}; | ||
|
||
main().catch(() => process.exit(1)); |
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 @@ | ||
{ | ||
"extends": "@augu/tsconfig", | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"typeRoots": ["./src/@types", "./node_modules/@types"], | ||
"rootDir": "./src", | ||
"types": ["node"], | ||
"outDir": "./build", | ||
"skipLibCheck": true, | ||
"noEmit": true // @vercel/ncc will compile it, so TypeScript won't. | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["src/**/*.ts"] | ||
} |
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,173 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@actions/core@^1.5.0": | ||
version "1.5.0" | ||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.5.0.tgz#885b864700001a1b9a6fba247833a036e75ad9d3" | ||
integrity sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ== | ||
|
||
"@actions/[email protected]": | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.0.0.tgz#1754127976c50bd88b2e905f10d204d76d1472f8" | ||
integrity sha512-QvE9eAAfEsS+yOOk0cylLBIO/d6WyWIOvsxxzdrPFaud39G6BOkUwScXZn1iBzQzHyu9SBkkLSWlohDWdsasAQ== | ||
dependencies: | ||
"@actions/http-client" "^1.0.11" | ||
"@octokit/core" "^3.4.0" | ||
"@octokit/plugin-paginate-rest" "^2.13.3" | ||
"@octokit/plugin-rest-endpoint-methods" "^5.1.1" | ||
|
||
"@actions/http-client@^1.0.11": | ||
version "1.0.11" | ||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0" | ||
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg== | ||
dependencies: | ||
tunnel "0.0.6" | ||
|
||
"@augu/[email protected]": | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/@augu/tsconfig/-/tsconfig-1.1.1.tgz#1c3a80f0734749a63f85ebf5b22889de9ab2e976" | ||
integrity sha512-qTqAK8+kTefw3PTixTFUHYATvl5inkFKnz3ByaYXO6P0prq5csA2T4weyVSWzR7dKL7rto9kHXnnN/8bTuPTKg== | ||
|
||
"@augu/[email protected]": | ||
version "1.5.3" | ||
resolved "https://registry.yarnpkg.com/@augu/utils/-/utils-1.5.3.tgz#eb82352e2690b0467ef690885e6496f0e7a12da9" | ||
integrity sha512-Pyu+JoK7f7AUjZvffCjf6ZLEpwa09ig7WNOn/ozzZDGeWNad9PMj8EsYzVsKLRyP/SnvbLDvpRWGEObgcACtYg== | ||
|
||
"@octokit/auth-token@^2.4.4": | ||
version "2.5.0" | ||
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" | ||
integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g== | ||
dependencies: | ||
"@octokit/types" "^6.0.3" | ||
|
||
"@octokit/[email protected]", "@octokit/core@^3.4.0": | ||
version "3.5.1" | ||
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b" | ||
integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw== | ||
dependencies: | ||
"@octokit/auth-token" "^2.4.4" | ||
"@octokit/graphql" "^4.5.8" | ||
"@octokit/request" "^5.6.0" | ||
"@octokit/request-error" "^2.0.5" | ||
"@octokit/types" "^6.0.3" | ||
before-after-hook "^2.2.0" | ||
universal-user-agent "^6.0.0" | ||
|
||
"@octokit/endpoint@^6.0.1": | ||
version "6.0.12" | ||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658" | ||
integrity sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA== | ||
dependencies: | ||
"@octokit/types" "^6.0.3" | ||
is-plain-object "^5.0.0" | ||
universal-user-agent "^6.0.0" | ||
|
||
"@octokit/graphql@^4.5.8": | ||
version "4.8.0" | ||
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" | ||
integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg== | ||
dependencies: | ||
"@octokit/request" "^5.6.0" | ||
"@octokit/types" "^6.0.3" | ||
universal-user-agent "^6.0.0" | ||
|
||
"@octokit/openapi-types@^10.2.2": | ||
version "10.2.2" | ||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-10.2.2.tgz#6c1c839d7d169feabaf1d2a69c79439c75d979cd" | ||
integrity sha512-EVcXQ+ZrC04cg17AMg1ofocWMxHDn17cB66ZHgYc0eUwjFtxS0oBzkyw2VqIrHBwVgtfoYrq1WMQfQmMjUwthw== | ||
|
||
"@octokit/plugin-paginate-rest@^2.13.3": | ||
version "2.16.3" | ||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.16.3.tgz#6dbf74a12a53e04da6ca731d4c93f20c0b5c6fe9" | ||
integrity sha512-kdc65UEsqze/9fCISq6BxLzeB9qf0vKvKojIfzgwf4tEF+Wy6c9dXnPFE6vgpoDFB1Z5Jek5WFVU6vL1w22+Iw== | ||
dependencies: | ||
"@octokit/types" "^6.28.1" | ||
|
||
"@octokit/plugin-rest-endpoint-methods@^5.1.1": | ||
version "5.10.4" | ||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.10.4.tgz#97e85eb7375e30b9bf193894670f9da205e79408" | ||
integrity sha512-Dh+EAMCYR9RUHwQChH94Skl0lM8Fh99auT8ggck/xTzjJrwVzvsd0YH68oRPqp/HxICzmUjLfaQ9sy1o1sfIiA== | ||
dependencies: | ||
"@octokit/types" "^6.28.1" | ||
deprecation "^2.3.1" | ||
|
||
"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" | ||
integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== | ||
dependencies: | ||
"@octokit/types" "^6.0.3" | ||
deprecation "^2.0.0" | ||
once "^1.4.0" | ||
|
||
"@octokit/request@^5.6.0": | ||
version "5.6.1" | ||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.1.tgz#f97aff075c37ab1d427c49082fefeef0dba2d8ce" | ||
integrity sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ== | ||
dependencies: | ||
"@octokit/endpoint" "^6.0.1" | ||
"@octokit/request-error" "^2.1.0" | ||
"@octokit/types" "^6.16.1" | ||
is-plain-object "^5.0.0" | ||
node-fetch "^2.6.1" | ||
universal-user-agent "^6.0.0" | ||
|
||
"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.28.1": | ||
version "6.28.1" | ||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.28.1.tgz#ab990d1fe952226055e81c7650480e6bacfb877c" | ||
integrity sha512-XlxDoQLFO5JnFZgKVQTYTvXRsQFfr/GwDUU108NJ9R5yFPkA2qXhTJjYuul3vE4eLXP40FA2nysOu2zd6boE+w== | ||
dependencies: | ||
"@octokit/openapi-types" "^10.2.2" | ||
|
||
"@vercel/[email protected]": | ||
version "0.31.1" | ||
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.31.1.tgz#9346c7e59326f5eeac75c0286e47df94c2d6d8f7" | ||
integrity sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA== | ||
|
||
before-after-hook@^2.2.0: | ||
version "2.2.2" | ||
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" | ||
integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== | ||
|
||
deprecation@^2.0.0, deprecation@^2.3.1: | ||
version "2.3.1" | ||
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" | ||
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== | ||
|
||
is-plain-object@^5.0.0: | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" | ||
integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== | ||
|
||
node-fetch@^2.6.1: | ||
version "2.6.2" | ||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.2.tgz#986996818b73785e47b1965cc34eb093a1d464d0" | ||
integrity sha512-aLoxToI6RfZ+0NOjmWAgn9+LEd30YCkJKFSyWacNZdEKTit/ZMcKjGkTRo8uWEsnIb/hfKecNPEbln02PdWbcA== | ||
|
||
once@^1.4.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" | ||
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= | ||
dependencies: | ||
wrappy "1" | ||
|
||
[email protected]: | ||
version "0.0.6" | ||
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" | ||
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== | ||
|
||
[email protected]: | ||
version "4.4.3" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" | ||
integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA== | ||
|
||
universal-user-agent@^6.0.0: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" | ||
integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== | ||
|
||
wrappy@1: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" | ||
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= |
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
File renamed without changes.
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,19 @@ | ||
name: ESLint Workflow | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
jobs: | ||
shortlinks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js v16 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Run the shortlinks script | ||
working-directory: .actions/build | ||
run: node shortlinks.js |
File renamed without changes.
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ node_modules/ | |
old_locales/ | ||
.husky/_/ | ||
build/ | ||
!.actions/build/ | ||
|
||
# Jest | ||
coverage/ | ||
|
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.