Skip to content

Commit 84c21ae

Browse files
committed
Test 1 yml
1 parent d7d4dc5 commit 84c21ae

2 files changed

Lines changed: 131 additions & 140 deletions

File tree

.github/workflows/release.yml

Lines changed: 131 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name: 'Release'
33
on:
44
push:
55
branches:
6-
- master
6+
# - master
7+
- set-up-oidc-publishing-2
8+
9+
issue_comment:
10+
types: [created]
711

812
env:
9-
npm-token: ${{ secrets.NPM_TOKEN }}
1013
github-token: ${{ secrets.GITHUB_TOKEN }}
1114
node-version: '24.x'
15+
snapshot-release-tag: pr${{ github.event.issue.number }}-run${{ github.run_number }}-${{ github.run_attempt }}
1216

1317
jobs:
1418
release:
@@ -32,13 +36,131 @@ jobs:
3236
- name: Install packages
3337
run: yarn install --prefer-offline
3438

35-
- name: Create Release Pull Request or Publish to NPM
36-
id: changesets
37-
uses: changesets/[email protected]
39+
# - name: Create Release Pull Request or Publish to NPM
40+
# id: changesets
41+
# uses: changesets/[email protected]
42+
# with:
43+
# publish: yarn release
44+
# commit: 'chore(release): update packages versions'
45+
# title: 'Upcoming Release Changes'
46+
# env:
47+
# GITHUB_TOKEN: ${{ env.github-token }}
48+
49+
release-snapshot-check:
50+
if: github.event.comment != ''
51+
runs-on: ubuntu-24.04
52+
permissions:
53+
pull-requests: write
54+
outputs:
55+
triggered: ${{ steps.check.outputs.triggered }}
56+
steps:
57+
- name: Acknowledge deployment request to commenter
58+
id: check
59+
uses: khan/[email protected]
60+
with:
61+
trigger: '/release-snapshot'
62+
reaction: rocket
63+
env:
64+
GITHUB_TOKEN: ${{ env.github-token }}
65+
66+
- name: Validate user
67+
if: ${{ steps.check.outputs.triggered == 'true' }}
68+
run: |
69+
if [[ "${AUTHOR_ASSOCIATION}" != 'OWNER' ]]
70+
then
71+
echo "User authorization failed"
72+
exit 1
73+
else
74+
echo "User authorization successful"
75+
exit 0
76+
fi
77+
env:
78+
AUTHOR_ASSOCIATION: ${{ github.event.comment.author_association }}
79+
80+
- name: Report failure
81+
if: failure()
82+
uses: octokit/[email protected]
83+
with:
84+
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
85+
owner: ${{ github.repository_owner }}
86+
repo: ${{ github.event.repository.name }}
87+
issue_number: ${{ github.event.issue.number }}
88+
body: '❌ No permission to release snapshot'
89+
env:
90+
GITHUB_TOKEN: ${{ env.github-token }}
91+
92+
release-snapshot:
93+
runs-on: ubuntu-24.04
94+
needs: release-snapshot-check
95+
permissions:
96+
id-token: write # allows ODIC publishing
97+
contents: read
98+
pull-requests: write # allows posting a message to the PR about success/error
99+
if: needs.release-snapshot-check.outputs.triggered == 'true'
100+
steps:
101+
- name: Get Pull Request ref
102+
id: get_pull_request_ref
103+
uses: octokit/[email protected]
104+
with:
105+
route: GET /repos/{owner}/{repo}/pulls/{issue_number}
106+
owner: ${{ github.repository_owner }}
107+
repo: ${{ github.event.repository.name }}
108+
issue_number: ${{ github.event.issue.number }}
109+
env:
110+
GITHUB_TOKEN: ${{ env.github-token }}
111+
112+
- name: Check out repository
113+
uses: actions/checkout@v4
114+
with:
115+
persist-credentials: true
116+
repository: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.repo.full_name }}
117+
ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }}
118+
119+
- name: Set up Node.js
120+
uses: actions/setup-node@v4
121+
with:
122+
node-version: ${{ env.node-version }}
123+
registry-url: 'https://registry.npmjs.org'
124+
cache: yarn
125+
cache-dependency-path: '**/yarn.lock'
126+
127+
- uses: ./.github/workflows/_publish.yml
128+
with:
129+
github-token: ${{ env.github-token }}
130+
snapshot-release-tag: ${{ env.release-tag }}
131+
132+
- name: Install deps
133+
run: yarn install --prefer-offline
134+
135+
- name: Deploy snapshot
136+
run: |
137+
yarn changeset version --snapshot $RELEASE_TAG
138+
yarn nx run-many --target=build
139+
yarn changeset publish --tag $RELEASE_TAG --no-git-tag
140+
env:
141+
GITHUB_TOKEN: ${{ env.github-token }}
142+
RELEASE_TAG: ${{ env.release-tag }}
143+
144+
- name: Report success
145+
if: success()
146+
uses: octokit/[email protected]
147+
with:
148+
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
149+
owner: ${{ github.repository_owner }}
150+
repo: ${{ github.event.repository.name }}
151+
issue_number: ${{ github.event.issue.number }}
152+
body: '✅ Successfully published package/s with tag `${{ env.release-tag }}`!'
153+
env:
154+
GITHUB_TOKEN: ${{ env.github-token }}
155+
156+
- name: Report failure
157+
if: failure()
158+
uses: octokit/[email protected]
38159
with:
39-
publish: yarn release
40-
commit: 'chore(release): update packages versions'
41-
title: 'Upcoming Release Changes'
160+
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
161+
owner: ${{ github.repository_owner }}
162+
repo: ${{ github.event.repository.name }}
163+
issue_number: ${{ github.event.issue.number }}
164+
body: '❌ Failed to publish package/s with tag `${{ env.release-tag }}`'
42165
env:
43166
GITHUB_TOKEN: ${{ env.github-token }}
44-
NPM_TOKEN: ${{ env.npm-token }}

.github/workflows/snapshot.yml

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)