Skip to content

Commit

Permalink
Switch to typescript based Action (#42)
Browse files Browse the repository at this point in the history
Switching to TypeScript to make the Action more reliable and testable.
Added support for GitHub Container Registry.
  • Loading branch information
lucacome authored Oct 11, 2024
1 parent 5102cdf commit c00cbc3
Show file tree
Hide file tree
Showing 48 changed files with 13,140 additions and 362 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = tab

[*.{md,yml,yaml}]
indent_size = 2
indent_style = space
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
lib/
node_modules/
jest.config.js
/.yarn/
39 changes: 39 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"env": {
"es6": true,
"jest": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"plugin:import/warnings",
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jest",
"prettier"
],
"rules": {
"import/no-unresolved": [
"error",
{
"ignore": [
"csv-parse/sync",
"@octokit/openapi-types"
]
}
],
"jest/no-disabled-tests": 0
}
}
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
8 changes: 0 additions & 8 deletions .github/dependabot.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
change:
- head-branch: ['^change/']

enhancement:
- head-branch: ['^feature/', '^feat/', '^enhancement/', '^enh/']

bug:
- head-branch: ['^fix/', '^bug/']

chore:
- head-branch: ['^chore/']

tests:
- head-branch: ['^tests/', '^test/']
- changed-files:
- any-glob-to-any-file: ['__tests__/**/*']

documentation:
- head-branch: ['^docs/', '^doc/']
- changed-files:
- any-glob-to-any-file: '**/*.md'

dependencies:
- head-branch: ['^deps/', '^dep/', '^dependabot/', '^renovate/']
- changed-files:
- any-glob-to-any-file: ['package.json', 'yarn.lock']
3 changes: 0 additions & 3 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ changelog:
- title: 📝 Documentation
labels:
- documentation
- title: 📦 Helm Chart
labels:
- helm_chart
- title: 🧪 Tests
labels:
- tests
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch: # yamllint disable-line rule:empty-values

permissions:
contents: read

concurrency:
group: ${{ github.ref_name }}-check-dist
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
check-dist:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Set Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version-file: .nvmrc

- name: Install dependencies
run: |
corepack yarn install
- name: Rebuild the dist/ directory
run: |
corepack yarn build
- name: Compare the expected and actual dist/ directories
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

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
18 changes: 18 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Dependency Review
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4
19 changes: 0 additions & 19 deletions .github/workflows/draft-release.yaml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create Draft Release Notes

on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"

jobs:
draft-release:
name: Create Draft Release
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Draft Release Notes
uses: lucacome/[email protected]
with:
minor-label: "enhancement"
major-label: "change"
publish: ${{ github.ref_type == 'tag' }}
18 changes: 18 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Pull Request Labeler"
on:
- pull_request_target

permissions:
contents: read

jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-24.04
steps:
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
76 changes: 76 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Lint

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

concurrency:
group: ${{ github.ref_name }}-lint
cancel-in-progress: true

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Set Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version-file: .nvmrc

- name: Install dependencies
run: |
corepack yarn install
- name: Lint the code
run: |
corepack yarn run lint
- name: Run format check
run: |
corepack yarn run format
- name: Check for uncommitted changes
run: |
if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after linting. See status below:"
git diff
exit 1
fi
actionlint:
name: Actionlint
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- uses: reviewdog/action-actionlint@7eeec1dd160c2301eb28e1568721837d084558ad # v1.57.0
with:
actionlint_flags: -shellcheck ""

markdown-lint:
name: Markdown Lint
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- uses: DavidAnson/markdownlint-cli2-action@db43aef879112c3119a410d69f66701e0d530809 # v17.0.0
with:
config: .markdownlint-cli2.yaml
globs: '**/*.md'
fix: false
61 changes: 61 additions & 0 deletions .github/workflows/renovate-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Run build for renovate PRs

on:
pull_request:
types: [opened, synchronize]

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
check:
runs-on: ubuntu-24.04
outputs:
javascript: ${{ steps.filter.outputs.javascript }}
steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Check for changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
javascript:
- 'package.json'
- 'yarn.lock'
build:
if: ${{ github.actor == 'renovate[bot]' && needs.check.outputs.javascript == 'true' }}
runs-on: ubuntu-24.04
needs: check
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.COMMIT_PAT }}

- name: Set up Node.js
uses:
actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .nvmrc

- name: Install dependencies
run: corepack yarn install

- name: Run build
run: corepack yarn build

- name: Commit changes
id: commit
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
with:
commit_message: 'Update dist/ after build'
Loading

0 comments on commit c00cbc3

Please sign in to comment.