Skip to content

Commit

Permalink
Merge pull request #55 from Borales/migration
Browse files Browse the repository at this point in the history
Migration on TS
  • Loading branch information
Borales committed Nov 26, 2022
2 parents fdf0082 + 4c27ffd commit 5841a21
Show file tree
Hide file tree
Showing 23 changed files with 10,328 additions and 95 deletions.
7 changes: 0 additions & 7 deletions .dockerignore

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintignore
@@ -0,0 +1,4 @@
dist/
lib/
node_modules/
jest.config.js
61 changes: 61 additions & 0 deletions .eslintrc.json
@@ -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
}
}
47 changes: 47 additions & 0 deletions .github/workflows/check-dist.yml
@@ -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 changes: 0 additions & 21 deletions .github/workflows/docker-publish.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
node_modules
lib

.DS_Store
Thumbs.db
3 changes: 3 additions & 0 deletions .prettierignore
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
10 changes: 10 additions & 0 deletions .prettierrc.json
@@ -0,0 +1,10 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG

## 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))
Expand Down
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

44 changes: 17 additions & 27 deletions README.md
Expand Up @@ -4,9 +4,6 @@
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

An example workflow how to install packages via Yarn (using repository syntax):
Expand All @@ -19,36 +16,29 @@ jobs:
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
```

> `cmd` value will be used as a command for Yarn
### 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).
21 changes: 10 additions & 11 deletions action.yml
@@ -1,21 +1,20 @@
name: 'GitHub Action for Yarn'
description: 'Wraps the yarn CLI to enable common yarn commands'
author: 'Alex Bordun'
branding:
icon: 'package'
color: 'blue'
inputs:
cmd:
description: 'Yarn command'
required: true
auth-token:
description: 'NPM_AUTH_TOKEN'
registry-url:
description: 'NPM_REGISTRY_URL'
# auth-token:
# description: 'NPM_AUTH_TOKEN'
# registry-url:
# description: 'NPM_REGISTRY_URL'
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'
# env:
# NPM_AUTH_TOKEN: ${{ inputs.auth-token }}
# NPM_REGISTRY_URL: ${{ inputs.registry-url }}

0 comments on commit 5841a21

Please sign in to comment.