-
Notifications
You must be signed in to change notification settings - Fork 3
51 lines (49 loc) · 1.73 KB
/
release-pr-package.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: release-pr-package
# SECURITY NOTE:
# pull_request_target is used to run the workflow on pull requests from ANY FORK!
# This is required to have access to the secret to publish the PR to npm.
# For that reason, any outside collaborator requires approval from a contributor.
# https://github.com/redhat-developer/red-hat-developer-hub-theme/settings/actions
on:
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
release-pr-package:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Publish to npm
run: |
# bash
short_sha=${GITHUB_SHA::7}
npm version "0.0.0-pr-${{ github.event.number }}-${short_sha}" --no-git-tag-version
npm publish --access=public --tag=latest-pr
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Add comment
uses: actions/github-script@v7
with:
script: |
// js
short_sha = process.env.GITHUB_SHA.slice(0, 7)
version = `0.0.0-pr-${{ github.event.number }}-${short_sha}`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `New package is available at: \`@redhat-developer/red-hat-developer-hub-theme@${version}\``
})