Skip to content

Commit

Permalink
feat: Implement first version
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Apr 26, 2024
1 parent 516c370 commit 96681c4
Show file tree
Hide file tree
Showing 23 changed files with 5,652 additions and 6,641 deletions.
41 changes: 0 additions & 41 deletions .devcontainer/devcontainer.json

This file was deleted.

13 changes: 3 additions & 10 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
env:
commonjs: true
es6: true
jest: true
node: true

globals:
Expand All @@ -15,25 +14,18 @@ ignorePatterns:
- '**/coverage/.*'
- '*.json'

parser: '@babel/eslint-parser'

parserOptions:
ecmaVersion: 2023
sourceType: module
requireConfigFile: false
babelOptions:
babelrc: false
configFile: false
presets:
- jest

plugins:
- jest

extends:
- eslint:recommended
- plugin:github/recommended
- plugin:jest/recommended
- plugin:@typescript-eslint/recommended

rules:
{
Expand All @@ -43,8 +35,9 @@ rules:
'i18n-text/no-en': 'off',
'import/no-commonjs': 'off',
'import/no-namespace': 'off',
'import/no-unresolved': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off'
'semi': 'off',
}
16 changes: 0 additions & 16 deletions .prettierrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions CODEOWNERS

This file was deleted.

2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
MIT License

Copyright 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
Expand Down
150 changes: 75 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ need to perform some initial setup steps before you can develop your action.
1. :hammer_and_wrench: Install the dependencies

```bash
npm install
```
```bash
npm install
```

1. :building_construction: Package the JavaScript for distribution

```bash
npm run bundle
```
```bash
npm run bundle
```

1. :white_check_mark: Run the tests

```bash
$ npm test
```bash
$ npm test
PASS ./index.test.js
✓ throws invalid number (3ms)
wait 500 ms (504ms)
test runs (95ms)
PASS ./index.test.js
✓ throws invalid number (3ms)
wait 500 ms (504ms)
test runs (95ms)
...
```
...
```

## Update the Action Metadata

Expand All @@ -84,62 +84,62 @@ contents of this directory with your own code.

There are a few things to keep in mind when writing your action code:

- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously.
In `main.js`, you will see that the action is run in an `async` function.
- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously.
In `main.js`, you will see that the action is run in an `async` function.

```javascript
const core = require('@actions/core')
//...
```javascript
const core = require('@actions/core')
//...
async function run() {
try {
//...
} catch (error) {
core.setFailed(error.message)
async function run() {
try {
//...
} catch (error) {
core.setFailed(error.message)
}
}
}
```
```

For more information about the GitHub Actions toolkit, see the
[documentation](https://github.com/actions/toolkit/blob/master/README.md).
For more information about the GitHub Actions toolkit, see the
[documentation](https://github.com/actions/toolkit/blob/master/README.md).

So, what are you waiting for? Go ahead and start customizing your action!

1. Create a new branch

```bash
git checkout -b releases/v1
```
```bash
git checkout -b releases/v1
```

1. Replace the contents of `src/` with your action code
1. Add tests to `__tests__/` for your source code
1. Format, test, and build the action

```bash
npm run all
```
```bash
npm run all
```

> [!WARNING]
>
> This step is important! It will run [`ncc`](https://github.com/vercel/ncc)
> to build the final JavaScript action code with all dependencies included.
> If you do not run this step, your action will not work correctly when it is
> used in a workflow. This step also includes the `--license` option for
> `ncc`, which will create a license file for all of the production node
> modules used in your project.
> [!WARNING]
>
> This step is important! It will run [`ncc`](https://github.com/vercel/ncc)
> to build the final JavaScript action code with all dependencies included.
> If you do not run this step, your action will not work correctly when it is
> used in a workflow. This step also includes the `--license` option for
> `ncc`, which will create a license file for all of the production node
> modules used in your project.

1. Commit your changes

```bash
git add .
git commit -m "My first action is ready!"
```
```bash
git add .
git commit -m "My first action is ready!"
```

1. Push them to your repository

```bash
git push -u origin releases/v1
```
```bash
git push -u origin releases/v1
```

1. Create a pull request and get feedback on your action
1. Merge the pull request into the `main` branch
Expand All @@ -158,19 +158,19 @@ action in the same repository.

```yaml
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Test Local Action
id: test-action
uses: ./
with:
milliseconds: 1000

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
- name: Checkout
id: checkout
uses: actions/checkout@v3
- name: Test Local Action
id: test-action
uses: ./
with:
milliseconds: 1000
- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
```

For example workflow runs, check out the
Expand All @@ -189,17 +189,17 @@ hash.

```yaml
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Run my Action
id: run-action
uses: actions/javascript-action@v1 # Commit with the `v1` tag
with:
milliseconds: 1000

- name: Print Output
id: output
run: echo "${{ steps.run-action.outputs.time }}"
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Run my Action
id: run-action
uses: actions/javascript-action@v1 # Commit with the `v1` tag
with:
milliseconds: 1000
- name: Print Output
id: output
run: echo "${{ steps.run-action.outputs.time }}"
```
18 changes: 0 additions & 18 deletions __tests__/index.test.js

This file was deleted.

14 changes: 14 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, it, vi } from 'vitest'

const main = vi.hoisted(() => ({
run: vi.fn(),
}))
vi.mock('../src/main', () => main)

describe('index', () => {
it('calls run when imported', async () => {
await import('../src/index.js')

expect(main.run).toHaveBeenCalled()
})
})
Loading

0 comments on commit 96681c4

Please sign in to comment.