Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workflows): publish job #276

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ jobs:
event: ${{ github.event.pull_request.number }}
pr-number: ${{ github.event.number }}
commit-sha: ${{ github.event.pull_request.head.sha }}
publish: true
11 changes: 8 additions & 3 deletions .github/workflows/publish.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ on:
type: string
description: The base sha
required: true
publish:
type: boolean
description: Flag to indicate whether to run the publish job
required: false
default: false

jobs:
publish:
if: ${{ github.event.inputs.publish }}
if: ${{ inputs.publish }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -40,15 +45,15 @@ jobs:

# if the branch is the default branch, the latest tag is applied
- name: Publish package on NPM [latest] 📦
if: ${{ inputs.event }} == commit
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.event_name == 'push'
run: npm publish --access public
working-directory: plugins/${{ inputs.affected-plugin }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# if the branch is not the default branch, the beta tag is applied
- name: Publish package on NPM [beta] 📦
if: ${{ inputs.event }} == pull_request
if: (github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && github.event_name == 'push') || github.event_name == 'pull_request'
run: |
VERSION=$(cat package-lock.json | jq -r '.version')
SHORT_SHA=$(echo ${{ inputs.commit-sha }} | cut -c1-7)
Expand Down
Loading