generated from iadvize/hello-world-javascript-library
-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (74 loc) · 2.77 KB
/
deployment.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
name: Deployment
on: deployment
jobs:
npm:
name: 'Deploy on npm'
runs-on: ubuntu-18.04
steps:
- name: Update deployment status
uses: actions/[email protected]
env:
DEPLOYMENT_ID: ${{ github.event.deployment.id }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
previews: 'ant-man,flash'
script: |
const name = context.payload.deployment.payload.name;
const version = context.payload.deployment.payload.version;
const npmUrl = `https://www.npmjs.com/package/${name}/v/${version}`;
const { data: deploymentStatus } = github.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: process.env.DEPLOYMENT_ID,
environment_url: npmUrl,
description: `Deployed ${name}@${version} on npm`,
auto_inactive: false,
state: 'in_progress',
});
- name: Checkout code
uses: actions/checkout@master
with:
ref: ${{ github.event.deployment.payload.ref }}
- name: Git config
run: |
git config user.name "Github actions"
git config user.email "[email protected]"
- uses: actions/setup-node@v1
with:
registry-url: https://registry.npmjs.org/
node-verion: '12.x'
- name: Install
run: npm ci
- name: Publish npm
id: publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ github.event.deployment.payload.version }}
TAG: ${{ github.event.deployment.payload.npmTag }}
run: |
npm version $VERSION --allow-same-version --no-git-tag-version
npm publish --access public --tag $TAG
echo "::set-output name=state::done"
- name: Update deployment status
if: always()
uses: actions/[email protected]
env:
DEPLOYMENT_ID: ${{ github.event.deployment.id }}
PUBLISH_STATE: ${{ steps.publish.outputs.state }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
previews: 'ant-man,flash'
script: |
const name = context.payload.deployment.payload.name;
const version = context.payload.deployment.payload.version;
const npmUrl = `https://www.npmjs.com/package/${name}/v/${version}`;
const state = process.env.PUBLISH_STATE === 'done' ? 'success' : 'failure';
const { data: deploymentStatus } = github.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: process.env.DEPLOYMENT_ID,
environment_url: npmUrl,
description: `Deployed ${name}@${version} on npm`,
auto_inactive: false,
state,
});