Skip to content

Commit 918b4d0

Browse files
IlyasShabibengl
andauthored
Fix github tag push (#7959)
* use dd-octo-sts for tag creation * fix: address review feedback for dd-octo-sts integration - Rename STS policy file to self.github.release.push-tags.sts.yaml - Remove unreliable ref_protected claim - Update policy references in release workflow - Remove unnecessary contents:write and pull-requests:read permissions * persist tag for dev --------- Co-authored-by: Bryan English <bryan.english@datadoghq.com>
1 parent 4072507 commit 918b4d0

2 files changed

Lines changed: 58 additions & 12 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
issuer: https://token.actions.githubusercontent.com
2+
3+
subject: repo:DataDog/dd-trace-js:environment:npm
4+
5+
claim_pattern:
6+
event_name: (push|workflow_dispatch)
7+
ref: refs/heads/(v[345]\.x|master)
8+
repository: DataDog/dd-trace-js
9+
job_workflow_ref: DataDog/dd-trace-js/\.github/workflows/release\.yml@refs/heads/(v[345]\.x|master)
10+
11+
permissions:
12+
contents: write

.github/workflows/release.yml

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ jobs:
2121
url: https://npmjs.com/package/dd-trace
2222
permissions:
2323
id-token: write
24-
contents: write
25-
pull-requests: read
2624
env:
2725
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2826
steps:
27+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
28+
id: octo-sts
29+
with:
30+
scope: DataDog/dd-trace-js
31+
policy: self.github.release.push-tags
2932
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3033
- uses: ./.github/actions/node
3134
- run: npm publish --tag latest-node14
@@ -35,7 +38,7 @@ jobs:
3538
echo "json=$content" >> $GITHUB_OUTPUT
3639
- run: |
3740
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
38-
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
41+
git push https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com/${{ github.repository }}.git v${{ fromJson(steps.pkg.outputs.json).version }}
3942
- run: node scripts/release/notes
4043

4144
publish-v4:
@@ -46,11 +49,14 @@ jobs:
4649
url: https://npmjs.com/package/dd-trace
4750
permissions:
4851
id-token: write
49-
contents: write
50-
pull-requests: read
5152
env:
5253
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5354
steps:
55+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
56+
id: octo-sts
57+
with:
58+
scope: DataDog/dd-trace-js
59+
policy: self.github.release.push-tags
5460
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5561
- uses: ./.github/actions/node
5662
- run: npm publish --tag latest-node16
@@ -60,7 +66,7 @@ jobs:
6066
echo "json=$content" >> $GITHUB_OUTPUT
6167
- run: |
6268
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
63-
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
69+
git push https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com/${{ github.repository }}.git v${{ fromJson(steps.pkg.outputs.json).version }}
6470
- run: node scripts/release/notes
6571

6672
publish-latest:
@@ -71,12 +77,17 @@ jobs:
7177
url: https://npmjs.com/package/dd-trace
7278
permissions:
7379
id-token: write
74-
contents: write
75-
pull-requests: read
7680
env:
7781
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7882
steps:
83+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
84+
id: octo-sts
85+
with:
86+
scope: DataDog/dd-trace-js
87+
policy: self.github.release.push-tags
7988
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89+
with:
90+
persist-credentials: false
8091
- uses: ./.github/actions/node
8192
- run: npm publish
8293
- id: pkg
@@ -85,7 +96,7 @@ jobs:
8596
echo "json=$content" >> $GITHUB_OUTPUT
8697
- run: |
8798
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
88-
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}
99+
git push https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com/${{ github.repository }}.git v${{ fromJson(steps.pkg.outputs.json).version }}
89100
- run: node scripts/release/notes --latest
90101

91102
docs:
@@ -130,9 +141,15 @@ jobs:
130141
url: https://npmjs.com/package/dd-trace
131142
permissions:
132143
id-token: write
133-
contents: write
134144
steps:
145+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
146+
id: octo-sts
147+
with:
148+
scope: DataDog/dd-trace-js
149+
policy: self.github.release.push-tags
135150
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
151+
with:
152+
persist-credentials: false
136153
- uses: ./.github/actions/node
137154
- uses: ./.github/actions/install
138155
- id: pkg
@@ -143,5 +160,22 @@ jobs:
143160
- run: npm publish --tag dev
144161
- run: |
145162
git tag --force dev
146-
git push origin :refs/tags/dev
147-
git push origin --tags
163+
git push https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com/${{ github.repository }}.git :refs/tags/dev
164+
git push https://x-access-token:${{ steps.octo-sts.outputs.token }}@github.com/${{ github.repository }}.git --tags
165+
166+
status:
167+
needs: ["publish-v3", "publish-v4", "publish-latest"]
168+
if: always() && contains(needs.*.result, 'success')
169+
runs-on: ubuntu-latest
170+
permissions:
171+
id-token: write
172+
contents: read
173+
pull-requests: read
174+
env:
175+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176+
steps:
177+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
178+
with:
179+
sparse-checkout: scripts/release/status.js
180+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
181+
- run: node scripts/release/status.js

0 commit comments

Comments
 (0)