This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
2 changed files
with
112 additions
and
1 deletion.
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,110 @@ | ||
# Based on https://github.com/Shopify/polaris | ||
|
||
name: Snapshot Release | ||
|
||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
snapshot: | ||
name: Snapshot Release | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.event.issue.pull_request && | ||
github.event.comment.body == '/snapshot' && | ||
github.repository == 'pedakihq/pedaki' | ||
steps: | ||
- name: Add initial reaction | ||
uses: peter-evans/create-or-update-comment@v2 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: eyes | ||
|
||
- name: Enforce permission requirement | ||
id: check-permissions | ||
continue-on-error: true | ||
uses: prince-chrismc/check-actor-permissions-action@v2 | ||
with: | ||
permission: write | ||
|
||
- name: Add reaction if permission requirement not met | ||
if: steps.check-permissions.outcome == 'failure' | ||
uses: peter-evans/create-or-update-comment@v2 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: confused | ||
body: | | ||
@${{ github.actor }} you do not have permission to run this command. | ||
Please ask a maintainer to run this command for you. | ||
- name: Exit if permission requirement not met | ||
if: steps.check-permissions.outcome == 'failure' | ||
run: exit 1 | ||
|
||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Because changeset entries are consumed and removed on the | ||
# 'changeset-release/main' branch, we need to reset the files | ||
# so the following 'changeset version --snapshot' command will | ||
# regenerate the package version bumps with the snapshot releases | ||
- name: Reset changeset entries on changeset-release/main branch | ||
run: | | ||
if [[ $(git branch --show-current) == 'changeset-release/main' ]]; then | ||
git checkout origin/main -- .changeset | ||
fi | ||
- uses: pnpm/action-setup@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: pnpm | ||
cache-dependency-path: pnpm-lock.yaml | ||
|
||
- name: Install deps | ||
run: pnpm install --child-concurrency 3 --frozen-lockfile --prefer-offline | ||
|
||
- name: Run Changeset | ||
id: changeset | ||
run: | | ||
pnpm exec changeset version --snapshot | ||
pnpm run publish:prepare | ||
pnpm exec changeset publish --tag | ||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: pnpm run publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Format changeset comment | ||
id: format-comment | ||
run: | | ||
changesetComment=$(echo "${{ steps.changesets.outputs.changeset-comment }}" | jq '.[] | "\(.name)@\(.version)"') | ||
echo "changesetComment=$changesetComment" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Send success comment | ||
uses: peter-evans/create-or-update-comment@v2 | ||
if: steps.changesets.outputs.published == 'true' | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
reactions: rocket | ||
body: | | ||
@${{ github.actor }} your snapshot release has been published! | ||
``` | ||
${{ steps.format-comment.outputs.changesetComment }} | ||
``` |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
node_modules | ||
node_modules | ||
.envrc |