Skip to content

Commit

Permalink
refactor: ci jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
ashgw committed Feb 23, 2025
1 parent eda4108 commit d87003f
Show file tree
Hide file tree
Showing 12 changed files with 5,637 additions and 4,574 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Build

on:
pull_request:
workflow_dispatch:
workflow_call:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Lint Knip (Production Only)

on:
pull_request:
workflow_dispatch:
workflow_call:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Prettier

on:
pull_request:
workflow_dispatch:
workflow_call:

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-spelling.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Lint Spelling

on:
pull_request:
workflow_dispatch:
workflow_call:

Expand Down
65 changes: 24 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,27 @@ on:
branches:
- main

pull_request:
types:
- opened
- synchronize

workflow_dispatch:

permissions:
contents: write
issues: write
pull-requests: write

concurrency:
group: Release
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
validate-pr:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/validate-pr-title.yml
secrets: inherit
format:
uses: ./.github/workflows/check-formatting.yml
lint:
Expand All @@ -26,7 +37,7 @@ jobs:
test:
uses: ./.github/workflows/test.yml

green-light:
mergeable:
if: always()
needs:
- lint
Expand All @@ -40,43 +51,15 @@ jobs:
id: all-green
with:
jobs: ${{ toJSON(needs)}}
docs:
runs-on: ubuntu-latest
needs:
- green-light
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run build:docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./docs
keep_files: true
npm:
needs:
- green-light
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/prepare

- name: Build
run: pnpm run build
docs:
if: github.ref == 'refs/heads/main'
needs: [mergeable]
uses: ./.github/workflows/docs.yml
secrets: inherit

- name: Release
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > ~/.npmrc
#!/bin/bash
if ! pnpm can-npm-publish; then
exit 0
fi
pnpm publish --no-git-checks --access public
npm:
if: github.ref == 'refs/heads/main'
needs: [mergeable]
uses: ./.github/workflows/npm.yml
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Docs

on:
workflow_dispatch:
workflow_call:

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run build:docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./docs
keep_files: true
30 changes: 30 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: NPM

on:
workflow_dispatch:
workflow_call:

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/prepare

- name: Build
run: pnpm run build

- name: Release
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > ~/.npmrc
#!/bin/bash
if ! pnpm can-npm-publish; then
exit 0
fi
pnpm publish --no-git-checks --access public
43 changes: 43 additions & 0 deletions .github/workflows/validate-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR

on:
workflow_dispatch:
workflow_call:

jobs:
validate-title:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: 'ashgw/ashgw.me'

- name: Assign PR to opener
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
OPENER: ${{ github.event.pull_request.user.login }}
run: |
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-X POST \
-d "{\"assignees\": [\"${OPENER}\"]}" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/assignees
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on PR if title lint fails
if: always() && steps.lint_pr_title.outputs.error_message != null
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
message: |
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
12 changes: 12 additions & 0 deletions CHANGELOG.md

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

3 changes: 2 additions & 1 deletion dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Immutate
roids
Nums
Nand
Numerify
Numerify
ashgw
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-roids",
"version": "1.41.3",
"version": "1.41.4",
"private": false,
"description": "Bullet-proof TS even more",
"type": "module",
Expand Down
Loading

0 comments on commit d87003f

Please sign in to comment.