Skip to content

Commit 3292820

Browse files
committed
debugging for github action: fix original snapit
1 parent d4a1137 commit 3292820

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

.github/workflows/snapit.yml

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ jobs:
2626
comment-id: ${{ github.event.comment.id }}
2727
reactions: eyes
2828

29+
- name: Get PR branch
30+
uses: xt0rted/pull-request-comment-branch@v1
31+
id: comment-branch
32+
33+
- name: Set latest commit status as pending
34+
uses: myrotvorets/set-commit-status-action@master
35+
with:
36+
sha: ${{ steps.comment-branch.outputs.head_sha }}
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
status: pending
39+
2940
- name: Validate pull request
3041
uses: actions/github-script@v6
3142
id: pr_data
@@ -60,17 +71,11 @@ jobs:
6071
- name: Checkout default branch
6172
uses: actions/checkout@v3
6273

63-
# issue_comment requires us to checkout the branch
64-
# https://github.com/actions/checkout/issues/331#issuecomment-1120113003
6574
- name: Checkout pull request branch
6675
run: hub pr checkout ${{ github.event.issue.number }}
6776
env:
6877
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6978

70-
# Because changeset entries are consumed and removed on the
71-
# 'changeset-release/main' branch, we need to reset the files
72-
# so the following 'changeset version --snapshot' command will
73-
# regenerate the package version bumps with the snapshot releases
7479
- name: Reset changeset entries on changeset-release/main branch
7580
run: |
7681
if [[ $(git branch --show-current) == 'changeset-release/main' ]]; then
@@ -95,6 +100,7 @@ jobs:
95100
96101
- name: Create and publish snapshot release
97102
uses: actions/github-script@v6
103+
id: snapshot-release
98104
env:
99105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100106
with:
@@ -132,10 +138,45 @@ jobs:
132138
repo: context.repo.repo,
133139
body,
134140
})
141+
core.setOutput('succeeded', 'true')
142+
} else {
143+
await github.rest.issues.createComment({
144+
issue_number: context.issue.number,
145+
owner: context.repo.owner,
146+
repo: context.repo.repo,
147+
body: `💥 Snapshot release unsuccessful! No tags have been found. ` +
148+
'Did you run `yarn changeset` and committed your changes?',
149+
})
150+
core.setOutput('succeeded', 'false')
151+
core.setFailed('No snapshot tags have been found')
135152
}
136153
137154
- name: Add final reaction
138155
uses: peter-evans/create-or-update-comment@v2
156+
if: ${{ steps.snapshot-release.outputs.succeeded == 'true' }}
139157
with:
140158
comment-id: ${{ github.event.comment.id }}
141159
reactions: rocket
160+
161+
- name: Add final reaction
162+
uses: peter-evans/create-or-update-comment@v2
163+
if: ${{ steps.snapshot-release.outputs.succeeded == 'false' }}
164+
with:
165+
comment-id: ${{ github.event.comment.id }}
166+
reactions: confused
167+
168+
- name: Create and publish snapshot release
169+
uses: actions/github-script@v6
170+
env:
171+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172+
with:
173+
script: |
174+
const execa = require('execa')
175+
176+
- name: Set latest commit status as ${{ job.status }}
177+
uses: myrotvorets/set-commit-status-action@master
178+
if: always()
179+
with:
180+
sha: ${{ steps.comment-branch.outputs.head_sha }}
181+
token: ${{ secrets.GITHUB_TOKEN }}
182+
status: ${{ job.status }}

0 commit comments

Comments
 (0)