Skip to content

25.8.2

25.8.2 #11

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/setup-node@v3
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- uses: actions/checkout@v3
- 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 for EInvoicing
id: get_bearer_token_einvoicing
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_EINVOICING=${token}" >> $GITHUB_ENV
- name: Retrieve bearer token for A1099
id: get_bearer_token_a1099
run: |
response=$(curl -X POST ${{secrets.AI_SBX_URL}}/connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=${{secrets.AI_CLIENT_ID_A1099}}&client_secret=${{secrets.AI_CLIENT_SECRET_A1099}}")
token=$(echo $response | jq -r '.access_token')
echo "BEARER_TOKEN_A1099=${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_EINVOICING: ${{ env.BEARER_TOKEN_EINVOICING }}
BEARER_TOKEN_A1099: ${{ env.BEARER_TOKEN_A1099 }}
- 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 }}