Update npm/publish/action.yaml

This commit is contained in:
Zakary Timson 2023-12-15 03:36:42 +00:00
parent dd59f1a57d
commit d8785ba71c

View File

@ -17,19 +17,25 @@ inputs:
required: false required: false
description: Access Token description: Access Token
default: ${{secrets.DEPLOY_TOKEN}} default: ${{secrets.DEPLOY_TOKEN}}
branch:
type: string
required: false
description: Only publish for branch
default: develop
runs: runs:
using: composite using: composite
steps: steps:
- name: Setup registry - name: Setup registry
run: | run: |
if [ "${{github.ref_name}}" == "develop" ]; then if [ "${{github.ref_name}}" == "${{inputs.branch}}" ]; then
TRIMMED=$(echo "${{inputs.registry}}" | sed s%http:%% | sed s%https:%%)
echo "_authToken=${{inputs.token}}" > .npmrc echo "_authToken=${{inputs.token}}" > .npmrc
echo "registry=${{inputs.registry}}/api/packages/${{inputs.owner}}/npm/" >> .npmrc echo "registry=$TRIMMED/api/packages/${{inputs.owner}}/npm/" >> .npmrc
fi fi
shell: sh shell: sh
- name: Publish - name: Publish
uses: docker://node uses: docker://node
with: with:
args: /bin/sh -c "npm publish" args: /bin/sh -c "[ \"${{github.ref_name}}\" == \"${{inputs.branch}}\" ] && npm publish"