Skip to content

Commit

Permalink
Publish snapshots on every pull request (#3320)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 authored Jul 22, 2024
1 parent dc56044 commit 755c45c
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Snapshot

on:
issue_comment:
types: [created]
pull_request:
branches: [main, next-minor, next-major]
push:
branches: [main, next-minor, next-major]

jobs:
snapshot:
name: Snapshot
if: ${{ github.repository_owner == 'Effect-Ts' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/snapshot') }}
if: ${{ github.repository_owner == 'Effect-Ts' && github.event.issue.pull_request }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
Expand All @@ -21,19 +23,7 @@ jobs:
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
- name: Initial comment
id: comment
uses: peter-evans/create-or-update-comment@v4
env:
Expand All @@ -57,7 +47,7 @@ jobs:
id: branch
run: echo "branch=$(git branch --show-current)" >> $GITHUB_OUTPUT

- name: Retrieve changeset entries
- name: Checkout main branch for changeset release
if: ${{ steps.branch.outputs.branch == 'changeset-release/main' }}
run: git checkout origin/main

Expand Down Expand Up @@ -87,13 +77,14 @@ jobs:
script: |
const commands = ${{ steps.snapshot.outputs.snapshots }}.map((snapshot) => {
const [package, installer] = snapshot.split(": ")
const [, sha] = installer.split(/@(?=[^@]*$)/)
const header = `<b>${package} (${sha}):</b><br />`
const header = `<b>${package}:</b><br />`
const content = "\n```sh\n" + installer + "\n```\n"
return [header, content].join("\n")
})
const header = `**Good news @${{ github.actor }}, your snapshot has been published!**\n\n`
+ `You can review the build log [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
+ "\n"
+ "Commit: ${{ github.event.head.sha }}"
const packages = `<details><summary><b>Packages:</b></summary>\n\n${commands.join("\n")}\n\n</details>`
Expand Down

0 comments on commit 755c45c

Please sign in to comment.