Compare commits

..

19 Commits
v3 .. v4

Author SHA1 Message Date
Borales 97ba8bebfe Added proper support for multiple arguments 2022-12-05 21:31:43 +01:00
Oleksandr Bordun d8b5ea8c26 Merge pull request #61 from Borales/renovate/eslint-8.x
Update dependency eslint to ^8.29.0
2022-12-05 21:02:01 +01:00
renovate[bot] ac4aa8b421 Update dependency eslint to ^8.29.0 2022-12-03 01:23:11 +00:00
Oleksandr Bordun d0b398ccef Merge pull request #60 from Borales/renovate/node-18.x
Update dependency @types/node to ^18.11.10
2022-12-02 22:37:02 +01:00
renovate[bot] 32394b360b Update dependency @types/node to ^18.11.10 2022-11-30 20:59:09 +00:00
Borales b257940aaa Adding readme note 2022-11-27 21:37:50 +01:00
Oleksandr Bordun 062383b267 Merge pull request #57 from Borales/renovate/configure
Configure Renovate
2022-11-27 16:24:05 +01:00
Borales d236877258 Updating renovate config 2022-11-27 16:22:16 +01:00
renovate[bot] 21a4e475d0 Add renovate.json 2022-11-27 15:10:36 +00:00
Borales 16098ef84e Updating readme 2022-11-26 23:40:08 +01:00
Oleksandr Bordun 9e77a0618b Merge pull request #56 from Borales/dir
Adding "dir" option
2022-11-26 23:37:02 +01:00
Borales 17af3bf048 Adding "dir" option 2022-11-26 23:35:32 +01:00
Oleksandr Bordun 5841a21eef Merge pull request #55 from Borales/migration
Migration on TS
2022-11-26 23:14:42 +01:00
Borales 4c27ffd69f Cleanup 2022-11-26 23:14:05 +01:00
Borales 0790298b9b Cleanup 2022-11-26 23:13:48 +01:00
Borales d2ca561aa5 Updating cwd 2022-11-26 22:25:09 +01:00
Borales 37ae1f22f9 Bumping actions/upload-artifact ver 2022-11-26 22:02:20 +01:00
Borales 9b8f6b01d0 Publishing dist 2022-11-26 21:59:16 +01:00
Borales 6bc995441e Initial migration on TS 2022-11-26 21:54:41 +01:00
24 changed files with 10361 additions and 95 deletions
-7
View File
@@ -1,7 +0,0 @@
# ignore all files by default
*
# include required files with an exception
!entrypoint.sh
!LICENSE
!README.md
!THIRD_PARTY_NOTICE.md
+4
View File
@@ -0,0 +1,4 @@
dist/
lib/
node_modules/
jest.config.js
+61
View File
@@ -0,0 +1,61 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{ "accessibility": "no-public" }
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{ "allowExpressions": true }
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
+13
View File
@@ -0,0 +1,13 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", "group:typescript-eslintMonorepo"],
"labels": ["dependencies"],
"rangeStrategy": "bump",
"reviewers": ["borales"],
"packageRules": [
{
"matchSourceUrlPrefixes": ["https://github.com/actions/toolkit"],
"groupName": "GitHub Actions Toolkit"
}
]
}
+47
View File
@@ -0,0 +1,47 @@
# https://github.com/actions/typescript-action/blob/main/.github/workflows/check-dist.yml
name: Check dist/
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Node.js 16.x
uses: actions/setup-node@v3.5.1
with:
node-version: 16.x
- name: Install dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: |
npm run build
npm run package
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
-21
View File
@@ -1,21 +0,0 @@
name: Publish Docker image
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: borales/yarn
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
cache: true
+5
View File
@@ -0,0 +1,5 @@
node_modules
lib
.DS_Store
Thumbs.db
+3
View File
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
+10
View File
@@ -0,0 +1,10 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
}
+12
View File
@@ -1,5 +1,17 @@
# CHANGELOG
## 4.2.0 (5 Dev 2022)
- Added proper support for multiple arguments
## 4.1.0 (26 Nov 2022)
- Added `dir` option
## 4.0.0 (26 Nov 2022)
- Migrated to Actions toolkit
## 3.0.0 (8 Jun 2022)
- Migrating to Python3 (thanks to [@richard-chim](https://github.com/richard-chim))
-7
View File
@@ -1,7 +0,0 @@
FROM node:lts-alpine
RUN apk add --no-cache git python3 build-base
RUN npm i -g --force yarn
COPY "entrypoint.sh" "/entrypoint.sh"
ENTRYPOINT ["/entrypoint.sh"]
CMD ["help"]
+28 -27
View File
@@ -4,51 +4,52 @@
This Action for [yarn](https://yarnpkg.com) enables arbitrary actions with the `yarn` command-line client, including testing packages and publishing to a registry.
> **Please keep in mind** that this Action was originally written for GitHub Actions beta (when Docker was the only way of doing things).
Consider using [actions/setup-node](https://github.com/actions/setup-node) to work with Yarn. This repository will be mostly supporting the existing flows.
## Usage
> It is required to run `actions/setup-node@v3` before `borales/actions-yarn` in order to setup the desired node version.
An example workflow how to install packages via Yarn (using repository syntax):
```yml
name: CI
on: [push]
jobs:
build:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: borales/actions-yarn@v3.0.0
- uses: actions/checkout@v3
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
- uses: borales/actions-yarn@v3.0.0
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed
- name: Build production bundle
uses: borales/actions-yarn@v4
with:
cmd: build # will run `yarn build` command
- uses: borales/actions-yarn@v3.0.0
cmd: build:prod # will run `yarn build:prod` command
- name: Test the app
uses: borales/actions-yarn@v4
with:
cmd: test # will run `yarn test` command
- name: Run test in sub-folder
uses: borales/actions-yarn@v4
with:
cmd: test
dir: 'frontend' # will run `yarn test` in `frontend` sub folder
```
> `cmd` value will be used as a command for Yarn
>
> `dir` value will be used for Yarn `cwd`
### Secrets
* `NPM_AUTH_TOKEN` - **Optional**. The token to use for authentication with the npm registry. Required for `yarn publish` ([more info](https://docs.npmjs.com/getting-started/working_with_tokens))
### Environment variables
* `NPM_REGISTRY_URL` - **Optional**. To specify a registry to authenticate with. Defaults to `registry.npmjs.org`
* `NPM_CONFIG_USERCONFIG` - **Optional**. To specify a non-default per-user configuration file. Defaults to `$HOME/.npmrc` ([more info](https://docs.npmjs.com/misc/config#npmrc-files))
#### Example
To authenticate with, and publish to, a registry other than `registry.npmjs.org`:
```yml
- uses: borales/actions-yarn@v3.0.0
with:
auth-token: ${{ secrets.NPM_TOKEN }}
registry-url: someOtherRegistry.someDomain.net
```
More information about [private registry setup](https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#use-private-packages).
+7 -11
View File
@@ -1,5 +1,6 @@
name: 'GitHub Action for Yarn'
description: 'Wraps the yarn CLI to enable common yarn commands'
author: 'Alex Bordun'
branding:
icon: 'package'
color: 'blue'
@@ -7,15 +8,10 @@ inputs:
cmd:
description: 'Yarn command'
required: true
auth-token:
description: 'NPM_AUTH_TOKEN'
registry-url:
description: 'NPM_REGISTRY_URL'
dir:
description: 'Yarn sub-folder (if needed)'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.cmd }}
env:
NPM_AUTH_TOKEN: ${{ inputs.auth-token }}
NPM_REGISTRY_URL: ${{ inputs.registry-url }}
using: 'node16'
main: 'dist/index.js'
+4219
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+97
View File
@@ -0,0 +1,97 @@
@actions/core
MIT
The MIT License (MIT)
Copyright 2019 GitHub
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.
@actions/exec
MIT
The MIT License (MIT)
Copyright 2019 GitHub
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.
@actions/http-client
MIT
Actions Http Client for Node.js
Copyright (c) GitHub, Inc.
All rights reserved.
MIT License
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.
@actions/io
MIT
The MIT License (MIT)
Copyright 2019 GitHub
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.
tunnel
MIT
The MIT License (MIT)
Copyright (c) 2012 Koichi Kobayashi
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.
uuid
MIT
The MIT License (MIT)
Copyright (c) 2010-2020 Robert Kieffer and other contributors
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.
+1
View File
File diff suppressed because one or more lines are too long
-22
View File
@@ -1,22 +0,0 @@
#!/bin/sh
set -e
if [ -n "$NPM_AUTH_TOKEN" ]; then
# Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc
NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG:-"$HOME/.npmrc"}"
NPM_REGISTRY_URL="${NPM_REGISTRY_URL:-registry.npmjs.org}"
NPM_STRICT_SSL="${NPM_STRICT_SSL:-true}"
NPM_REGISTRY_SCHEME="https"
if ! $NPM_STRICT_SSL
then
NPM_REGISTRY_SCHEME="http"
fi
# Allow registry.npmjs.org to be overridden with an environment variable
printf "//%s/:_authToken=%s\\nregistry=%s\\nstrict-ssl=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "${NPM_REGISTRY_SCHEME}://$NPM_REGISTRY_URL" "${NPM_STRICT_SSL}" > "$NPM_CONFIG_USERCONFIG"
chmod 0600 "$NPM_CONFIG_USERCONFIG"
fi
sh -c "yarn $*"
+5764
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
{
"name": "@borales/actions-yarn",
"version": "4.2.0",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2"
},
"devDependencies": {
"@types/node": "^18.11.10",
"@typescript-eslint/parser": "^5.44.0",
"@vercel/ncc": "^0.34.0",
"eslint-plugin-github": "^4.4.1",
"eslint-plugin-jest": "^27.1.6",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"prettier": "^2.8.0",
"typescript": "^4.9.3"
}
}
+22
View File
@@ -0,0 +1,22 @@
import {debug, getInput, setFailed, getState} from '@actions/core'
import {ensureYarnIsInstalled} from './yarn'
import {run} from './run'
import {resolve} from 'path'
const main = async () => {
await ensureYarnIsInstalled()
const cmd: string = getInput('cmd', {required: true})
const dir: string = getInput('dir')
const cwd: string = resolve(getState('repositoryPath'), dir || '')
try {
debug(`Running "${cmd}" command`)
await run(cmd, {cwd})
} catch (error) {
if (error instanceof Error) setFailed(error.message)
}
}
main()
+5
View File
@@ -0,0 +1,5 @@
import {exec} from '@actions/exec'
export const run = async (cmd: string, {cwd}: {cwd: string}) => {
await exec('yarn', cmd.split(' '), {cwd})
}
+20
View File
@@ -0,0 +1,20 @@
import {debug, setOutput} from '@actions/core'
import {exec, getExecOutput} from '@actions/exec'
import {which} from '@actions/io'
export const ensureYarnIsInstalled = async () => {
try {
await which('yarn', true)
} catch (e) {
await exec('npm install --global yarn')
}
const [{stdout: yarnVersion}, {stdout: nodeVersion}] = await Promise.all([
getExecOutput('yarn', ['--version'], {silent: true}),
getExecOutput('node', ['--version'], {silent: true})
])
debug(`Node ${nodeVersion.trim()} detected`)
debug(`Yarn v${yarnVersion.trim()} detected`)
setOutput('yarn-version', yarnVersion.trim())
}
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"outDir": "./lib" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"exclude": ["node_modules", "**/*.test.ts"]
}