-
Notifications
You must be signed in to change notification settings - Fork 76
90 lines (79 loc) · 2.96 KB
/
build-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
85
86
87
88
89
90
name: Build Pull Request
on:
pull_request:
types: [labeled]
jobs:
build-canary:
if: github.event.action == 'labeled' && contains(github.event.label.name, 'Publish canary')
name: Build canary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
ssh-strict: false
- name: Set git configuration
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "[email protected]"
- uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: Restore/create node_modules cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
env:
HUSKY: 0
- name: Build sources
run: yarn build
- name: Publish canary
id: publish-canary
run: |
npm whoami
lerna publish --canary --preid $PR_NUMBER --no-verify-access --no-private --no-commit-hooks --no-changelog --yes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Manage pull request labels
uses: actions/github-script@v4
if: github.event_name == 'pull_request'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const name = 'Publish canary :hatched_chick:';
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
try {
await github.issues.removeLabel({
owner,
repo,
issue_number,
name,
});
} catch (e) { console.log(`Problem when trying to remove the "${name}" label : no big deal`); }
- name: 'New canary release: comment PR'
uses: actions/github-script@v4
if: github.event_name == 'pull_request'
id: build-canary-success-body
with:
github-token: ${{ github.token }}
result-encoding: string
script: |
const comment = [
':hatched_chick: **Canary published successfully** !',
'Check the workflow https://github.com/Decathlon/vitamin-web/runs/${{ github.run_id }}'
];
return comment.join('\n');
- name: Update Pull Request with canary version
uses: thollander/actions-comment-pull-request@v1
if: github.event_name == 'pull_request'
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_includes: 'Canary published successfully'
message: ${{ steps.build-canary-success-body.outputs.result }}