Skip to content

Commit

Permalink
fix prettier and targets validation
Browse files Browse the repository at this point in the history
  • Loading branch information
imyanice committed May 3, 2024
1 parent eeeccf9 commit bda83bb
Show file tree
Hide file tree
Showing 11 changed files with 611 additions and 596 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: Continuous Integration

on:
push:
branches:
- main
push:
branches:
- main

jobs:
test-action:
permissions:
contents: write
name: GitHub Actions Test
runs-on: macos-latest
test-action:
permissions:
contents: write
name: GitHub Actions Test
runs-on: macos-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__
releaseName: 'App v__VERSION__'
targets: 'aarch64-apple-darwin'
srcDir: './test-dir/'
- name: Test Local Action
id: test-action
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__
releaseName: 'App v__VERSION__'
targets: 'aarch64-apple-darwin'
srcDir: './test-dir/'
27 changes: 13 additions & 14 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
"tabWidth": 4,
"useTabs": true,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}
147 changes: 74 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,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 TypeScript 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 @@ -89,60 +89,61 @@ 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.ts`, 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.ts`, you will see that the action is run in an
`async` function.

```javascript
import * as core from '@actions/core'
//...
```javascript
import * as core from '@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
```

> 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.
> 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 @@ -161,19 +162,19 @@ action in the same repository.

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

- 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@v4
- 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 @@ -192,19 +193,19 @@ hash.

```yaml
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Test Local Action
id: test-action
uses: actions/typescript-action@v1 # Commit with the `v1` tag
with:
milliseconds: 1000

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

## Publishing a New Release
Expand Down
36 changes: 19 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ author: 'Your name or organization here'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'heart'
color: 'red'
icon: 'heart'
color: 'red'

# Define your inputs here.
inputs:
targets:
description: 'List of targets the action should create an executable for'
required: true
default: ''
srcDir:
description:
'The folder containing the "target" directory. AKA your source folder.'
required: false
default: './'
releaseName:
description: 'The name of the release to create'
tagName:
description: 'The tag name of the release to create'
targets:
description:
'List of targets the action should create an executable for'
required: true
default: ''
srcDir:
description:
'The folder containing the "target" directory. AKA your source
folder.'
required: false
default: './'
releaseName:
description: 'The name of the release to create'
tagName:
description: 'The tag name of the release to create'

runs:
using: node20
main: dist/index.js
using: node20
main: dist/index.js
8 changes: 6 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit bda83bb

Please sign in to comment.