Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add generate action and remove unit test code #3

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ACTIONS_STEP_DEBUG=true

# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
# Hyphens should not be converted to underscores!
INPUT_MILLISECONDS=2400
INPUT_COMMENT_TAG_NAME=HUGO_FIXIT_COMPONENTS

# GitHub Actions default environment variables. These are set for every run of a
# workflow and can be used in your actions. Setting the value here will override
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main

permissions:
contents: read
contents: write # To write the generated contents to the readme

jobs:
test-typescript:
Expand Down Expand Up @@ -40,10 +40,6 @@ jobs:
id: npm-lint
run: npm run lint

- name: Test
id: npm-ci-test
run: npm run ci-test

test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
Expand All @@ -56,9 +52,12 @@ jobs:
- name: Test Local Action
id: test-action
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
milliseconds: 2000
comment_tag_name: FIXIT_COMPONENTS
template: '- [{$repo.name}]({$repo.html_url})\\n {$repo.description}'

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
run: echo "${{ steps.test-action.outputs.repos }}"
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
dist/
node_modules/
coverage/
26 changes: 6 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ need to perform some initial setup steps before you can develop your action.
npm run bundle
```

3. :white_check_mark: Run the tests

```bash
$ npm test

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

...
```

## Update the Action Metadata

The [`action.yml`](action.yml) file defines metadata about your action, such as
Expand Down Expand Up @@ -85,8 +72,7 @@ So, what are you waiting for? Go ahead and start customizing your action!
```

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

```bash
npm run all
Expand All @@ -99,7 +85,7 @@ So, what are you waiting for? Go ahead and start customizing your action!
> `ncc`, which will create a license file for all of the production node
> modules used in your project.

5. (Optional) Test your action locally
4. (Optional) Test your action locally

The [`@github/local-action`](https://github.com/github/local-action) utility
can be used to test your action locally. It is a simple command-line tool
Expand Down Expand Up @@ -127,21 +113,21 @@ So, what are you waiting for? Go ahead and start customizing your action!
file, [`.env.example`](./.env.example), and the
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).

6. Commit your changes
5. Commit your changes

```bash
git add .
git commit -m "Feat: add new action code"
```

7. Push them to your repository
6. Push them to your repository

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

8. Create a pull request and get feedback on your action
9. Merge the pull request into the `main` branch
7. Create a pull request and get feedback on your action
8. Merge the pull request into the `main` branch

Your action is now published! :rocket:

Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
![CI](https://github.com/hugo-fixit/action-component-list/actions/workflows/ci.yml/badge.svg)
[![Check dist/](https://github.com/hugo-fixit/action-component-list/actions/workflows/check-dist.yml/badge.svg)](https://github.com/hugo-fixit/action-component-list/actions/workflows/check-dist.yml)
[![CodeQL](https://github.com/hugo-fixit/action-component-list/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/hugo-fixit/action-component-list/actions/workflows/codeql-analysis.yml)
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)

This is a GitHub Action to generate a list of all hugo-fixit theme components.

Expand All @@ -25,13 +24,33 @@ steps:
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
- name: Generate hugo-fixit component list
id: test-action
uses: hugo-fixit/action-component-list@v1 # Commit with the `v1` tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
milliseconds: 1000

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
```

## Example

Insert the following code block in your Markdown file to display the list of
hugo-fixit components.

```md
The list of hugo-fixit components will be displayed here.

<!-- HUGO_FIXIT_COMPONENTS:START -->
<!-- HUGO_FIXIT_COMPONENTS:END -->
```

The list of hugo-fixit components will be displayed here.

<!-- FIXIT_COMPONENTS:START -->

<!-- FIXIT_COMPONENTS:END -->
10 changes: 0 additions & 10 deletions __fixtures__/core.ts

This file was deleted.

3 changes: 0 additions & 3 deletions __fixtures__/wait.ts

This file was deleted.

62 changes: 0 additions & 62 deletions __tests__/main.test.ts

This file was deleted.

24 changes: 0 additions & 24 deletions __tests__/wait.test.ts

This file was deleted.

28 changes: 22 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@ branding:
color: blue

inputs:
milliseconds:
description: Your input description here
required: true
default: '1000'
comment_tag_name:
description:
Override the default comment tag name, if you want to show multiple
instances of the action on the same repo
required: false
default: HUGO_FIXIT_COMPONENTS
readme_path:
description: Comma separated paths of the readme files you want to update
required: false
default: './README.md'
exclude_repos:
description: Comma separated list of repos to exclude from the list
required: false
default: ''
template:
description:
'Template to use while creating the list of hugo-fixit theme components.
It can contain {$repo.name} etc. as variables'
default: '- [{$repo.name}]({$repo.html_url}): {$repo.description}'
required: false

outputs:
time:
description: Your output description here
repos:
description: The list of hugo-fixit theme components repos that were updated

runs:
using: node20
Expand Down
1 change: 0 additions & 1 deletion badges/coverage.svg

This file was deleted.

22 changes: 22 additions & 0 deletions dist/generate.d.ts

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

Loading
Loading