-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (109 loc) · 6.31 KB
/
tests.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Tests
on:
pull_request:
branches:
- develop
jobs:
tests:
runs-on: ubuntu-latest
steps:
# Get time of PR event trigger
- name: Get current time
uses: josStorer/[email protected]
id: current_time
with:
format: YYYYMMDD-HH
utcOffset: '+01:00'
# Checkout repository
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
# Get head commit message
- name: Print head git commit message
id: get_head_commit_message
run: echo "::set-output name=HEAD_COMMIT_MESSAGE::$(git show -s --format=%s)"
# Setup git user
- name: Setup git user
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config user.name "GitHub Actions Bot"
git config user.email "<>"
# Setup node
- uses: actions/setup-node@v3
with:
node-version: latest
# Install modules
- name: Installing modules
id: install_modules
run: |
rm -rf node_modules
yarn install
# Save release version
- name: Save release version to outputs
id: save_release_version
run: echo ::set-output name=version::$(node -pe "require('./pullRequestRelease.json').version")
# Run Unit Tests
- name: Running tests
env:
ENDPOINT_API: ${{ secrets.ENDPOINT_API}}
API_USER_NAME: ${{ secrets.API_USER_NAME}}
API_USER_PASS: ${{ secrets.API_USER_PASS }}
id: tests
run: yarn run test
# Test the build
- name: Build test
env:
ENDPOINT_API: ${{ secrets.ENDPOINT_API}}
API_USER_NAME: ${{ secrets.API_USER_NAME}}
API_USER_PASS: ${{ secrets.API_USER_PASS }}
id: build_test
run: yarn run build:test
# Build storybook documentation
- name: Build documentation JSON
id: build_docs_json
run: yarn docs
# Publish documentation to chromatic
- name: Publish to Chromatic
env:
ENDPOINT_API: ${{ secrets.ENDPOINT_API}}
API_USER_NAME: ${{ secrets.API_USER_NAME}}
API_USER_PASS: ${{ secrets.API_USER_PASS }}
id: chromatic_publish
uses: chromaui/action@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
exitZeroOnChanges: true
# Change package version to make release
- name: Change npm version
id: change_npm_version
run: npm version ${{ steps.save_release_version.outputs.version }} --no-git-tag-version --force
# Publish new release to NPM
- name: Publish to NPM
id: npm_publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
tag: pull_request_${{ steps.save_release_version.outputs.version }}
access: public
# Notify discord if all steps succeeded
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}}
DISCORD_EMBEDS: '[{ "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },"url": "https://github.com/${{github.repository}}/commit/${{github.sha}}","fields": [{ "name": "Commit Message", "value": "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"},{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/pull/${{github.ref_name}})", "inline": true },{ "name": "Event", "value": "${{github.event_name}}", "inline": true },{ "name": "Author", "value": "[${{github.actor}}](https://github.com/${{github.actor}})", "inline": true },{ "name": "Job", "value": "${{github.job}}", "inline": true},{ "name": "", "value": "🤖 [Github Action](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}}) 📙 [Documentation](${{ steps.chromatic_publish.outputs.storybookUrl }}) 🎨 [Chromatic Tests](${{ steps.chromatic_publish.outputs.buildUrl }})"}],"color":65280,"footer":{"text": "Published at ${{steps.current_time.outputs.readableTime}}"}}]'
DISCORD_AVATAR: 'https://raw.githubusercontent.com/qoretechnologies/qorus-toolkit/7d7988ad2be4388b1371f684278102d76f9ca5cb/public/q-symbol-small.png'
uses: Ilshidur/[email protected]
with:
args: ':white_check_mark: Release *v${{ steps.save_release_version.outputs.version }}* successfully created & published!'
if: success()
# Notify discord if all steps failed
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}}
DISCORD_EMBEDS: '[{ "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },"url": "https://github.com/${{github.repository}}/commit/${{github.sha}}","fields": [{ "name": "Commit Message", "value": "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"},{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/pull/${{github.ref_name}})", "inline": true },{ "name": "Event", "value": "${{github.event_name}}", "inline": true },{ "name": "Author", "value": "[${{github.actor}}](https://github.com/${{github.actor}})", "inline": true },{ "name": "Job", "value": "${{github.job}}", "inline": true },{ "name": "", "value": "🤖 [Github Action](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}})"}],"color":16711680,"footer":{"text": "Published at ${{steps.current_time.outputs.readableTime}}"}}]'
DISCORD_AVATAR: 'https://raw.githubusercontent.com/qoretechnologies/qorus-toolkit/7d7988ad2be4388b1371f684278102d76f9ca5cb/public/q-symbol-small.png'
uses: Ilshidur/[email protected]
with:
args: ':exclamation: Release *v${{ steps.save_release_version.outputs.version }}* failed!'
if: failure()