Skip to content

Commit

Permalink
set up from template
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemellander committed Apr 16, 2024
1 parent 4e6899e commit 2a6a341
Show file tree
Hide file tree
Showing 16 changed files with 3,142 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release

on:
pull_request:
paths:
- .github/workflows/release.yaml
push:
branches:
- main
tags:
- v*

jobs:
tag:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- run: yarn install
- run: yarn build
101 changes: 101 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
lib/

# Only release tag contains dist directory
/dist
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"semi": false,
"singleQuote": true
}
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.12.2
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# typescript-action
Template of TypeScript Action
## Getting Started
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: typescript-action
description: Template of TypeScript Action

inputs:
name:
description: example input
required: true

runs:
using: 'node20'
main: 'dist/index.js'
21 changes: 21 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check

import eslint from '@eslint/js'
import jest from 'eslint-plugin-jest'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{
ignores: ['.git/', 'node_modules/', 'dist/', 'eslint.config.js'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
jest.configs['flat/recommended'],
{
languageOptions: {
parserOptions: {
project: true,
},
},
},
)
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest/presets/default-esm',
clearMocks: true,
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"private": true,
"scripts": {
"format": "prettier --write **/*.ts",
"lint": "eslint .",
"build": "ncc build --source-map src/main.ts",
"test": "jest"
},
"type": "module",
"dependencies": {
"@actions/core": "1.10.1"
},
"devDependencies": {
"@tsconfig/node20": "20.1.4",
"@types/jest": "29.5.12",
"@types/node": "20.12.7",
"@vercel/ncc": "0.38.1",
"eslint": "9.0.0",
"eslint-plugin-jest": "28.2.0",
"jest": "29.7.0",
"prettier": "3.2.5",
"ts-jest": "29.1.2",
"typescript": "5.4.5",
"typescript-eslint": "7.7.0"
},
"engines": {
"node": "20.x"
}
}
13 changes: 13 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as core from '@actions/core'
import { run } from './run.js'

const main = async (): Promise<void> => {
await run({
name: core.getInput('name', { required: true }),
})
}

main().catch((e: Error) => {
core.setFailed(e)
console.error(e)
})
10 changes: 10 additions & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as core from '@actions/core'

type Inputs = {
name: string
}

// eslint-disable-next-line @typescript-eslint/require-await
export const run = async (inputs: Inputs): Promise<void> => {
core.info(`my name is ${inputs.name}`)
}
5 changes: 5 additions & 0 deletions tests/run.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { run } from '../src/run.js'

test('run successfully', async () => {
await expect(run({ name: 'foo' })).resolves.toBeUndefined()
})
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node20/tsconfig.json"
}
Loading

0 comments on commit 2a6a341

Please sign in to comment.