Skip to content

24.2.29

24.2.29 #2

Workflow file for this run

name: Publish package to npm
on:
release:
types: [published]
jobs:
publish-npm:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env
run: |
echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Print Version
run: |
echo $VERSION
echo ${{ env.VERSION }}
- run: npm ci
- run: npm run build
# Step to retrieve the bearer token
- name: Retrieve bearer token
id: get_bearer_token
run: |
response=$(curl -X POST ${{secrets.OKTA_ACCESS_TOKEN_URL}}/connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=${{secrets.OKTA_CLIENT_ID}}&client_secret=${{secrets.OKTA_CLIENT_SECRET}}")
token=$(echo $response | jq -r '.access_token')
echo "BEARER_TOKEN=${token}" >> $GITHUB_ENV
# Use the bearer token as an environment variable in the npm test command
- name: Run npm test with bearer token
run: npm run test
env:
BEARER_TOKEN: ${{ env.BEARER_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
- name: Update package.json version
run: |
jq --arg version "$VERSION" '.version = $version' package.json > temp.json && mv temp.json package.json
- name: Update resources
uses: test-room-7/action-update-file@v1
with:
file-path: package.json
commit-msg: Commit npm package version
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: cp ./README.md ./dist/README.md
- run: cp ./package.json ./dist/package.json
- run: npm publish ./dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}