-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (75 loc) · 3.21 KB
/
publish-pr.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Publish PR Packages
on:
workflow_run:
workflows: ["Create PR Artifact"]
types:
- completed
jobs:
publish_pr_packages:
name: NPM publish PR to Github
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Show context
run: |
echo github.event_name: ${{ github.event_name }}
echo github.sha: ${{ github.sha }}
echo github.repository: ${{ github.repository }}
echo github.ref: ${{ github.ref }}
echo github.head_ref: ${{ github.head_ref }}
echo github.base_ref: ${{ github.base_ref }}
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
- name: Get PR data
id: pr
run: |
ls -R pr-packages
pr_number=$(ls pr-packages)
n_packages=$(ls pr-packages/$pr_number | wc -l)
echo pr_number: $pr_number
echo n_packages: $n_packages
echo "::set-output name=pr_number::$pr_number"
echo "::set-output name=n_packages::$n_packages"
- name: Publish to github
run: |
pr_number="${{ steps.pr.outputs.pr_number }}"
tasks/npmrc-use-github.sh > pr-packages/$pr_number/.npmrc # using PAT
cd pr-packages/$pr_number
for f in `ls` ; do
npm --userconfig .npmrc publish $f --tag "PR$pr_number"
done
env:
PAT: ${{ secrets.PAT }}
- name: Find Comment
uses: peter-evans/find-comment@v1
if: ${{ steps.pr.outputs.n_packages > 0 }}
id: fc
with:
issue-number: ${{ steps.pr.outputs.pr_number }}
comment-author: "github-actions[bot]"
- name: Create comment
if: ${{ steps.pr.outputs.n_packages > 0 && steps.fc.outputs.comment-id == 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ steps.pr.outputs.pr_number }}
body: |
### 📦 treasure-contracts Package Installation
Install this PR (you need to setup Github packages):
```bash
yarn add @treasure-chess/treasure-contracts@PR${{ steps.pr.outputs.pr_number }} --registry https://npm.pkg.github.com
```
<details><summary>:octocat: Click to learn how to use Github packages</summary>
To use the Github package registry, create a token with "read:packages" permission. See [Creating a personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) for help.
Next add these lines to your `.npmrc` file, replacing TOKEN with your personal access token. See [Installing a package from Github](https://docs.github.com/en/packages/guides/configuring-npm-for-use-with-github-packages#installing-a-package) if you get stuck.
```
//npm.pkg.github.com/:_authToken=TOKEN
```
</details>