-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from Staffbase/feat/changeset-workflows
feat: changeset workflows
- Loading branch information
Showing
3 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Changeset Check | ||
|
||
on: workflow_call | ||
|
||
jobs: | ||
changeset-check: | ||
name: changeset-check | ||
if: (!contains(github.event.pull_request.user.login , '[bot]')) | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Check for changesets | ||
id: changeset-files | ||
uses: tj-actions/[email protected] | ||
with: | ||
files: .changeset/*.md | ||
base_sha: ${{ github.event.pull_request.base.sha }} | ||
|
||
- name: Find existing comment | ||
uses: peter-evans/[email protected] | ||
id: find_comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: "github-actions[bot]" | ||
body-includes: <!-- changeset-check --> | ||
|
||
- name: Update comment for found changeset | ||
uses: peter-evans/[email protected] | ||
if: steps.changeset-files.outputs.any_changed == 'true' | ||
with: | ||
comment-id: ${{ steps.find_comment.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
<!-- changeset-check --> | ||
## 🦋 Changeset file found | ||
Good job! A changeset file has been added in this PR. Your changes will be included in the next release. | ||
edit-mode: replace | ||
|
||
- name: Update comment for missing changeset | ||
uses: peter-evans/[email protected] | ||
if: steps.changeset-files.outputs.any_changed != 'true' | ||
with: | ||
comment-id: ${{ steps.find_comment.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
<!-- changeset-check --> | ||
## ⚠️ Changeset file missing | ||
No changeset file has been added in this PR. Please consider adding one if this PR contains user-facing changes. | ||
edit-mode: replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Changeset Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
node-version-file: | ||
default: '.nvmrc' | ||
required: false | ||
type: string | ||
publish-script: | ||
default: 'pnpm release' | ||
required: false | ||
type: string | ||
version-script: | ||
default: 'pnpm changeset version' | ||
required: false | ||
type: string | ||
node-registry: | ||
required: false | ||
type: string | ||
node-registry-scope: | ||
required: false | ||
type: string | ||
secrets: | ||
app_id: | ||
required: true | ||
private_key: | ||
required: true | ||
npm-token: | ||
required: true | ||
|
||
jobs: | ||
release: | ||
name: changeset-release | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Get App Token | ||
uses: actions/[email protected] | ||
id: get_token | ||
with: | ||
app-id: ${{ secrets.app_id }} | ||
private-key: ${{ secrets.private_key }} | ||
|
||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
token: ${{ steps.get_token.outputs.token }} | ||
|
||
- name: Setup PNPM | ||
uses: pnpm/[email protected] | ||
|
||
- name: Setup Node | ||
uses: actions/[email protected] | ||
with: | ||
node-version-file: ${{ inputs.node-version-file }} | ||
cache: 'pnpm' | ||
registry-url: ${{ inputs.node-registry }} | ||
scope: ${{ inputs.node-registry-scope }} | ||
|
||
- name: Install Dependencies | ||
run: pnpm install --frozen-lockfile --ignore-scripts | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.npm-token }} | ||
|
||
- name: Create Release Pull Request | ||
id: changesets | ||
uses: changesets/[email protected] | ||
with: | ||
commit: 'chore(release): Bump package version' | ||
title: '📦 Release New Version' | ||
createGithubReleases: true | ||
version: ${{ inputs.version-script }} | ||
publish: ${{ inputs.publish-script }} | ||
env: | ||
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} | ||
HOME: ${{ github.workspace }} | ||
NODE_AUTH_TOKEN: ${{ secrets.npm-token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,64 @@ jobs: | |
</details> | ||
### Changeset Check | ||
<details> | ||
<summary>The action can be used to check a PR for the existance of <a href="https://github.com/changesets/changesets">changeset</a> files. It will then add/update a comment on the PR.</summary> | ||
```yml | ||
name: Changeset Check | ||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
changeset-check: | ||
uses: Staffbase/gha-workflows/.github/workflows/[email protected] | ||
``` | ||
</details> | ||
### Changeset Release | ||
<details> | ||
<summary>The action can be used to create release PR and publish releases for repos using PNPM and <a href="https://github.com/changesets/changesets">changesets</a>.</summary> | ||
⚠️ Make sure you have `@changesets/cli` installed as a dev-dependency in your project! | ||
|
||
```yml | ||
name: Release Changesets | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
changeset-release: | ||
uses: Staffbase/gha-workflows/.github/workflows/[email protected] | ||
with: | ||
# optional: The file containing the Node.js version to use, defaults to .nvmrc | ||
node-version-file: '.node-version' | ||
# optional: The script to run on publish. Defaults to `pnpm release` | ||
publish-script: 'pnpm publish' | ||
# optional: The script to run for bumping the package versions. Defaults to `pnpm changeset version` | ||
version-script: 'pnpm version' | ||
# optional: The registry to use for Node.js packages. | ||
node-registry: 'https://npm.pkg.github.com/' | ||
# optional: The scope to use for Node.js packages. | ||
node-registry-scope: '@staffbase' | ||
secrets: | ||
# identifier of the GitHub App for authentication | ||
app-id: ${{ <your-app-id> }} | ||
# private key of the GitHub App | ||
private-key: ${{ <your-private-key> }} | ||
# needs write:packages rights | ||
npm-token ${{ <your-npm-token> }} | ||
``` | ||
|
||
</details> | ||
|
||
### GitOps | ||
|
||
<details> | ||
|