Skip to content

Add a drizzle-schema package #2634

Add a drizzle-schema package

Add a drizzle-schema package #2634

Workflow file for this run

name: Snapshot
on:
issue_comment:
types: [created]
jobs:
snapshot:
name: Snapshot
if: ${{ github.repository_owner == 'Effect-Ts' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/snapshot') }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
id-token: write
pull-requests: write
steps:
- name: Enforce permission requirement
uses: prince-chrismc/check-actor-permissions-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
permission: write
- name: Extract snapshot command
id: command
env:
COMMENT: ${{ github.event.comment.body }}
run: |
if [[ $COMMENT == "/snapshot" ]]; then
snapshot="${BASH_REMATCH[2]:-snapshot}"
echo "snapshot=$snapshot" >> $GITHUB_OUTPUT
else
exit 1
fi
- name: Create initial comment
id: comment
uses: peter-evans/create-or-update-comment@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
issue-number: ${{ github.event.issue.number }}
body: |
**Alright @${{ github.actor }}, I'm working on the snapshot!**
You can follow the progress [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
- name: Checkout default branch
uses: actions/checkout@v4
- name: Checkout pull request branch
run: gh pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get current branch name
id: branch
run: echo "branch=$(git branch --show-current)" >> $GITHUB_OUTPUT
- name: Retrieve changeset entries
if: ${{ steps.branch.outputs.branch == 'changeset-release/main' }}
run: git checkout origin/main
- name: Install dependencies
uses: ./.github/actions/setup
- name: Build package
run: pnpm build
- name: Create snapshot
id: snapshot
run: |
snapshots=$(pnpx pkg-pr-new@0.0.17 publish --pnpm --comment=off ./packages/*)
echo "${snapshots}"
snapshots=$(echo "${snapshots}" | awk '
/⚡️ Your npm packages are published./ \
{ found=1; next } found \
{ sub(/npm i/, "pnpm add"); print "\"" $0 "\"" }
' | paste -sd ',')
echo "snapshots=[$snapshots]" >> $GITHUB_OUTPUT
- name: Update comment (success)
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const commands = ${{ steps.snapshot.outputs.snapshots }}.map((snapshot) => {
const [package, installer] = snapshot.split(": ")
const [, sha] = installer.split(/@(?=[^@]*$)/)
const header = `<details><summary><b>${package} (${sha})</b></summary><p>`
const content = "\n```sh\n" + installer + "\n```\n"
const footer = `</p></details>`
return [header, content, footer].join("\n")
})
const header = `**Good news @${{ github.actor }}, your snapshot has been published!**`
const footer = `You can review the build log [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
await github.rest.issues.updateComment({
comment_id: ${{ steps.comment.outputs.comment-id }},
owner: context.repo.owner,
repo: context.repo.repo,
body: `${header}\n\n${commands.join("\n")}\n\n${footer}`
})
- name: Update comment (failure)
if: failure()
uses: peter-evans/create-or-update-comment@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: replace
body: |
**Sorry @${{ github.actor }}, I failed to publish the snapshot!**
You can review the build log [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).