Skip to content

Commit

Permalink
fix: using author's optic and npm tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehesi97 committed Sep 18, 2023
1 parent c30c483 commit cb8bd9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,36 @@ jobs:
private_key: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }}

- uses: google-github-actions/release-please-action@v3
id: release_please
with:
release-type: go
token: ${{ steps.get_installation_token.outputs.token }}
bump-minor-pre-major: true
package-name: release-please-action
extra-files: |
npm/package.json
- name: Get commit author
id: commit_author
run: |
author=$(gh pr list --search ${{ github.sha }} --state merged --json mergedBy --jq '.[0].mergedBy.login'
echo "author=${author}" >> $$GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }}

- uses: actions/setup-node@v3
# This sets up the .npmrc file for publishing to npm
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"

- run: |
cd npm
npm config set //registry.npmjs.org/:_authToken=${{ secrets[format('NPM_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.NPM_TOKEN }}
npm ci
otp=$(curl -s \
-d '{ "packageInfo": { "version": "$(cat package.json | jq -r '.version')", "name": "$(cat package.json | jq -r '.name')" } }' \
-H "Content-Type: application/json" \
-X POST \
https://optic-zf3votdk5a-ew.a.run.app/api/generate/${{ secrets[format('OPTIC_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.OPTIC_TOKEN }})
npm publish --otp ${otp} --access public --provenance
17 changes: 0 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,3 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v3
# This sets up the .npmrc file for publishing to npm
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"

- run: |
cd npm
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm ci
otp=$(curl -s \
-d '{ "packageInfo": { "version": "$(cat package.json | jq -r '.version')", "name": "$(cat package.json | jq -r '.name')" } }' \
-H "Content-Type: application/json" \
-X POST \
https://optic-zf3votdk5a-ew.a.run.app/api/generate/${{ secrets.OPTIC_TOKEN }})
npm publish --otp ${otp} --access public --provenance

0 comments on commit cb8bd9c

Please sign in to comment.