84 lines (82 loc) · 2.93 KB
/
canary.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
name: Canary Release
on:
pull_request:
branches:
- master
workflow_dispatch:
inputs:
onDemand:
description: 'Are you sure?'
required: true
default: 'yes'
npmTag:
description: 'NPM Tag'
required: true
default: 'alpha'
npmVersionSuffix:
description: 'Custom NPM Version Suffix'
required: false
jobs:
publish-canary:
name: Publish Canary
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository || github.event.inputs.onDemand == 'yes'
steps:
- name: Checkout Master
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node
uses: actions/setup-node@v3
with:
node-version: 17
- name: Configure Git Credentials
run: |
git config --global user.email "theguild-bot@users.noreply.github.com"
git config --global user.name "theguild-bot"
echo "machine github.com login theguild-bot password ${{secrets.GH_API_TOKEN}}" > ~/.netrc
- name: Setup NPM credentials
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Cache Yarn
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-17-16-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-17-16-yarn-
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Release Canary
id: canary
uses: 'kamilkisiela/release-canary@master'
with:
npm-token: ${{ secrets.NODE_AUTH_TOKEN }}
npm-script: 'yarn release:canary'
changesets: true
env:
ON_DEMAND: ${{github.event.inputs.onDemand}}
NPM_TAG: ${{github.event.inputs.npmTag || 'alpha'}}
NPM_VERSION_SUFFIX: ${{github.event.inputs.npmVersionSuffix}}
- name: Publish a message
if: steps.canary.outputs.released
uses: 'kamilkisiela/pr-comment@master'
with:
message: |
The latest changes of this PR are available as alpha in npm (based on the declared `changesets`):
```
${{ steps.canary.outputs.changesetsPublishedPackages}}
```
bot-token: ${{ secrets.GH_API_TOKEN }}
bot: 'theguild-bot'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish a empty message
if: steps.canary.outputs.released == 'false'
uses: 'kamilkisiela/pr-comment@master'
with:
message: |
The latest changes of this PR are not available as alpha, since there are no linked `changesets` for this PR.
bot-token: ${{ secrets.GH_API_TOKEN }}
bot: 'theguild-bot'
github-token: ${{ secrets.GITHUB_TOKEN }}