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

Convert to TS project #81

Merged
merged 18 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from 16 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
16 changes: 8 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"image": "mcr.microsoft.com/devcontainers/base",
"name": "Node.js",
"image": "mcr.microsoft.com/devcontainers/typescript-node:16",
"features": {
"ghcr.io/devcontainers-contrib/features/pnpm:2": {}
},
"customizations": {
"codespaces": {
"openFiles": ["README.md", "CONTRIBUTING.md"]
},
"vscode": {
"extensions": [
"lizebang.bash-extension-pack",
"EditorConfig.EditorConfig",
"GitHub.vscode-github-actions"
]
"extensions": ["EditorConfig.EditorConfig"]
}
},
// https://webinstall.dev/
"postCreateCommand": "curl -sS https://webi.sh/shfmt | sh && curl -sS https://webi.sh/shellcheck | sh"
"postCreateCommand": ".devcontainer/postCreate.sh",
Copy link
Contributor

@jcbhmr jcbhmr May 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-  "postCreateCommand": ".devcontainer/postCreate.sh",
+  "postCreateCommand": "pnpm install",

It is just one command after all 😂

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit of future-proofing for when more post-create commands need to be added. Plus, it's a cheat to add a bit more language diversity to this project 😉

"remoteUser": "node"
}
2 changes: 2 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
pnpm i
7 changes: 2 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
action.yml linguist-detectable

# This makes the newlines behave correctly in weird situations like running a
# Windows-mounted CRLF file from within a WSL shell that expects LF.
*.sh eol=lf
dist/* binary
tsconfig.json linguist-language=JSON-With-Comments
52 changes: 52 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- "**.md"

pull_request:
branches:
- main
paths-ignore:
- "**.md"

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Rebuild dist/
run: |
pnpm build
pnpm package

- name: Compare diff
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

- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: pnpm

- name: Install dependencies
run: pnpm install

- run: pnpm build
- run: pnpm package
- name: Test
run: pnpm test

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

format:
name: Check Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: pnpm

- name: Install dependencies
run: pnpm install

- run: pnpm format-check
36 changes: 0 additions & 36 deletions .github/workflows/test.yml

This file was deleted.

32 changes: 16 additions & 16 deletions .github/workflows/update-tags.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Update tags
on:
release:
types: [released]
concurrency:
group: update-tags
cancel-in-progress: true
permissions:
contents: write
jobs:
update-tags:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
source-tag: ${{ github.event.release.tag_name }}
name: Update tags
on:
release:
types: [released]
concurrency:
group: update-tags
cancel-in-progress: true
permissions:
contents: write
jobs:
update-tags:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
source-tag: ${{ github.event.release.tag_name }}
3 changes: 3 additions & 0 deletions .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to use https://github.com/github/gitignore/blob/main/Node.gitignore since it's "official" but that's just me 😊

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, besides the fact that it ignores dist/ by default AFAIK, there's no reason I'm not using it besides being to lazy to fetch that file 😆

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
/lib/
/coverage/
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/
/coverage/
/dist/
/lib/
pnpm-lock.yaml
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 88,
"trailingComma": "all"
}
72 changes: 35 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
**Thanks for taking the time to contribute! ❤️**

All types of contributions are encouraged and valued, no matter if it's a bug
report 🐛, a feature request 💡, or a Pull Request 🚀.

- **❓ I have a question:** [Open a Q&A Discussion]
- **🐛 I found a bug:** [Open an Issue]
- **💡 I have an idea:** [Open an Idea Discussion]
- **💻 I want to code:** See below

## Contributing code

1. 🔀 Fork the repo
2. 💻 Open the repo in your editor
3. 👨‍💻 Add your changes to your workspace
4. 🔖 Commit & push your changes
5. 🔁 Open a PR to get your changes merged
6. 🧪 Let the tests run to make sure everything works
7. 🚀 Profit!

🚀 For a seamless coding experience, we recommend using VS Code or GitHub
Codespaces as your editor! With VS Code's extensions and customizable settings,
you can tailor your environment to suit your preferences. 🌟 Plus, for GitHub
Codespaces users, we provide a `devcontainer.json` config for a ready-to-use
development environment. 🛠️ Enhance your coding productivity and enjoyment with
these powerful editors! 😊

We use [EditorConfig] to specify the spacing and file conventions for this
project. Make sure you _try_ to conform with it. Editors like VS Code have
extensions that will do this automatically for you! 😉

<!-- prettier-ignore-start -->
[open an issue]: https://github.com/spenserblack/actions-wiki/issues/new
[open a Q&A discussion]: https://github.com/spenserblack/actions-wiki/discussions/new?category=q-a
[open an idea discussion]: https://github.com/spenserblack/actions-wiki/discussions/new?category=ideas
[editorconfig]: https://editorconfig.org/
<!-- prettier-ignore-end -->
**Thanks for taking the time to contribute! ❤️**

All types of contributions are encouraged and valued, no matter if it's a bug
report 🐛, a feature request 💡, or a Pull Request 🚀.

- **❓ I have a question:** [Open a Q&A Discussion][new-qa]
- **🐛 I found a bug:** [Open an Issue][new-issue]
- **💡 I have an idea:** [Open an Idea Discussion][new-idea]
- **💻 I want to code:** See below

## Contributing code

1. 🔀 Fork the repo
2. 💻 Open the repo in your editor
3. 👨‍💻 Add your changes to your workspace
4. 🔖 Commit & push your changes
5. 🔁 Open a PR to get your changes merged
6. 🧪 Let the tests run to make sure everything works
7. 🚀 Profit!

🚀 For a seamless coding experience, we recommend using VS Code or GitHub
Codespaces as your editor! With VS Code's extensions and customizable settings,
you can tailor your environment to suit your preferences. 🌟 Plus, for GitHub
Codespaces users, we provide a `devcontainer.json` config for a ready-to-use
development environment. 🛠️ Enhance your coding productivity and enjoyment with
these powerful editors! 😊

We use [EditorConfig][editorconfig] to specify the spacing and file conventions for this
project. Make sure you _try_ to conform with it. Editors like VS Code have
extensions that will do this automatically for you! 😉

[new-issue]: https://github.com/spenserblack/actions-wiki/issues/new
[new-qa]: https://github.com/spenserblack/actions-wiki/discussions/new?category=q-a
[new-idea]: https://github.com/spenserblack/actions-wiki/discussions/new?category=ideas
[editorconfig]: https://editorconfig.org/
51 changes: 22 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

</div>

🌐 Works across repositories (with a [PAT]) \
🌐 Works across repositories (with a [PAT][pat]) \
📚 Pretty interface for Markdown docs \
⤴️ Lets you open PRs for wiki docs \
💻 Supports `runs-on: windows-*`
Expand Down Expand Up @@ -55,13 +55,13 @@ that powers the GitHub wiki. If you don't, when we push to `your-repo.wiki.git`,
your workflow will fail because the wiki doesn't exist.

⚠️ You'll need to remember to enable the `contents: write` permission! GitHub
recently [changed the default permissions granted to jobs] for new repositories.
recently [changed the default permissions granted to jobs][default-permissions-update] for new repositories.

### Publishing to a different repository

If you're pushing to a wiki that's **not the current repository** you'll need to
get a [GitHub PAT] to push to it. The default `${{ secrets.GITHUB_TOKEN }}`
won't cut it! You can [generate a PAT] in your GitHub Settings.
get a [GitHub PAT][pat] to push to it. The default `${{ secrets.GITHUB_TOKEN }}`
won't cut it! You can [generate a PAT][generate-a-pat] in your GitHub Settings.

For example, if you created octocat/gigantic-mega-project-wiki to hold the wiki
and you want to publish it to the GitHub wiki that belongs to _another
Expand Down Expand Up @@ -103,41 +103,34 @@ one of your GitHub Actions workflows.

## Alternatives

There are quite a few GitHub wiki publishing actions on the [GitHub Actions
marketplace]. There are, however, two that stick out. The
[newrelic/wiki-sync-action] is a good choice for if you need bidirectional
There are quite a few GitHub wiki publishing actions on the [GitHub Actions marketplace][actions-marketplace]. There are, however, two that stick out. The
[newrelic/wiki-sync-action][newrelic-action] is a good choice for if you need bidirectional
synchronization when someone edits the live wiki. This can be beneficial for
less-technical contributors. There's also [Andrew-Chen-Wang/github-wiki-action]
less-technical contributors. There's also [Andrew-Chen-Wang/github-wiki-action][andrew-chen-wang-action]
which is a direct competitor to this project. It offers more automatic features,
but has more complex configuration. It also [doesn't support `runs-on:
windows-*`].
but has more complex configuration. It also [doesn't support `runs-on: windows-*`](https://github.com/Andrew-Chen-Wang/github-wiki-action/discussions/28).

📚 If you're interested in more discussion of alternatives, check out [#4].
📚 If you're interested in more discussion of alternatives, check out [#4][issue-4].

## Development

![YAML](https://img.shields.io/static/v1?style=for-the-badge&message=YAML&color=CB171E&logo=YAML&logoColor=FFFFFF&label=)
![Bash](https://img.shields.io/static/v1?style=for-the-badge&message=Bash&color=4EAA25&logo=GNU+Bash&logoColor=FFFFFF&label=)

This is a GitHub Action, so we inevitably use YAML[^1]. Make sure you quote the
This is a GitHub Action, so we inevitably use [YAML][yaml-notes]. Make sure you quote the
right things! To test 🧪 the action, the current workflow is to open a PR and
then have the [`test.yml`] workflow run a `dry-run: true` iteration to
then have the [`test.yml`](https://github.com/spenserblack/actions-wiki/blob/main/.github/workflows/test.yml) workflow run a `dry-run: true` iteration to
(hopefully) spot any flaws.

To get a better handle on the contribution process, check out our handy
[contributing guide]. Happy coding! 👋

<!-- prettier-ignore-start -->
[newrelic/wiki-sync-action]: https://github.com/newrelic/wiki-sync-action#readme
[Andrew-Chen-Wang/github-wiki-action]: https://github.com/Andrew-Chen-Wang/github-wiki-action#readme
[#4]: https://github.com/spenserblack/actions-wiki/issues/4
[PAT]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
[GitHub PAT]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
[changed the default permissions granted to jobs]: https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
[github actions marketplace]: https://github.com/marketplace?type=actions
[generate a pat]: https://github.com/settings/tokens?type=beta
[doesn't support `runs-on: windows-*`]: https://github.com/Andrew-Chen-Wang/github-wiki-action/discussions/28
[contributing guide]: https://github.com/spenserblack/actions-wiki/blob/main/CONTRIBUTING.md
[`test.yml`]: https://github.com/spenserblack/actions-wiki/blob/main/.github/workflows/test.yml
[^1]: https://earthly.dev/blog/intercal-yaml-and-other-horrible-programming-languages/
<!-- prettier-ignore-end -->
[contributing guide][contributing]. Happy coding! 👋

[newrelic-action]: https://github.com/newrelic/wiki-sync-action#readme
[andrew-chen-wang-action]: https://github.com/Andrew-Chen-Wang/github-wiki-action#readme
[issue-4]: https://github.com/spenserblack/actions-wiki/issues/4
[pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
[default-permissions-update]: https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
[actions-marketplace]: https://github.com/marketplace?type=actions
[generate-a-pat]: https://github.com/settings/tokens?type=beta
[contributing]: https://github.com/spenserblack/actions-wiki/blob/main/CONTRIBUTING.md
[yaml-notes]: https://earthly.dev/blog/intercal-yaml-and-other-horrible-programming-languages/
Loading