Skip to content

Commit 2408a9c

Browse files
committed
fix(ci): scope v1 release tokens to this repository
1 parent 2aaa2f6 commit 2408a9c

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎.github/workflows/publish-npm.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ jobs:
343343
CLIENT_ID: ${{ vars.SOCKET_RELEASE_CLIENT_ID }}
344344
OWNER: ${{ github.repository_owner }}
345345
PERMISSIONS: '{"contents":"write"}'
346+
REPOSITORIES: ${{ github.event.repository.name }}
346347
run: node scripts/release/mint-app-token.mjs
347348

348349
# Derive the version from the commits since the last release, write
@@ -763,6 +764,7 @@ jobs:
763764
CLIENT_ID: ${{ vars.SOCKET_RELEASE_CLIENT_ID }}
764765
OWNER: ${{ github.repository_owner }}
765766
PERMISSIONS: '{"contents":"write"}'
767+
REPOSITORIES: ${{ github.event.repository.name }}
766768
run: node scripts/release/mint-app-token.mjs
767769

768770
- name: Land or discard the bump

‎test/release-workflow.test.mts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { describe, expect, it } from 'vitest'
44
import { parse } from 'yaml'
55

66
interface ReleaseStep {
7+
env?: Record<string, string>
78
name?: string
89
run?: string
910
uses?: string
@@ -12,6 +13,7 @@ interface ReleaseStep {
1213
interface ReleaseWorkflow {
1314
concurrency: { group: string; 'cancel-in-progress': boolean }
1415
jobs: {
16+
land: { steps: ReleaseStep[] }
1517
verify: {
1618
environment?: string
1719
outputs: { sha: string }
@@ -36,6 +38,19 @@ const workflow = parse(
3638
) as ReleaseWorkflow
3739

3840
describe('v1 release workflow contract', () => {
41+
it('scopes both release App tokens to the current repository', () => {
42+
const mintSteps = Object.values(workflow.jobs)
43+
.flatMap(job => job.steps)
44+
.filter(step => step.run === 'node scripts/release/mint-app-token.mjs')
45+
expect(mintSteps).toHaveLength(2)
46+
for (const step of mintSteps) {
47+
expect(step.env).toMatchObject({
48+
PERMISSIONS: '{"contents":"write"}',
49+
REPOSITORIES: '${{ github.event.repository.name }}',
50+
})
51+
}
52+
})
53+
3954
it('uses the migrated trusted publisher environment', () => {
4055
expect(workflow.jobs.publish.environment).toBe('publish-npm')
4156
expect(workflow.jobs.publish.permissions['id-token']).toBe('write')

0 commit comments

Comments
 (0)