-
Notifications
You must be signed in to change notification settings - Fork 8
142 lines (125 loc) · 4.56 KB
/
main.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: 'main'
on:
pull_request:
push:
branches:
- '**'
env:
GITHUB_SERVICE_USER: "rajsite"
GITHUB_SERVICE_EMAIL: "[email protected]"
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
LANGUAGE: "en_US.UTF-8"
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
# Required for beachball changelog detection
fetch-depth: 0
# Must checkout with a token that can push to protected branches for beachball
# Cannot rely on GITHUB_TOKEN with workflow contents permission
# See: https://github.com/orgs/community/discussions/40971
token: ${{ secrets.GITHUBPAGESDEPLOYTOKEN }}
# Install dependencies
- uses: actions/setup-dotnet@v3
with:
global-json-file: packages/nimble-blazor/global.json
- run: dotnet --info
working-directory: packages/nimble-blazor/
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
# Specify npm version
# See: https://github.com/actions/setup-node/issues/529
- run: npm i -g npm@9
- run: npm ci
# print a log of outdated npm dependencies
# only informational so swallow error codes
- run: npm outdated || exit 0
# Audit
- run: npm audit --only=prod
# https://github.com/ni/nimble/issues/801
# - run: npm audit --audit-level=critical
# Build
- run: npm run build
# Pack
- run: npm run pack
- uses: actions/upload-artifact@v3
with:
name: packages
path: |
packages/**/*.tgz
packages/**/*.nupkg
angular-workspace/**/*.tgz
if-no-files-found: error
# The actions/upload-pages-artifact@v1 results in unexpected warning messages, workaround for:
# https://github.com/actions/upload-pages-artifact/issues/45
- name: Pages file permission workaround
run: chmod -c -R +rX packages/site/dist
- uses: actions/upload-pages-artifact@v1
with:
path: 'packages/site/dist'
# Publish to Chromatic (from any push)
- name: Publish to Chromatic
if: github.event_name == 'push'
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
onlyChanged: "!startsWith(github.ref, 'refs/heads/main')" # Use TurboSnap for PR builds
workingDir: ./packages/nimble-components
externals: |
- '.storybook/public/**'
- '../packages/nimble-tokens/dist/icons/svg/**'
- '../packages/nimble-tokens/source/styledictionary/properties/**'
storybookBuildDir: ../../packages/site/dist/storybook
exitOnceUploaded: true # Do not wait for test results
exitZeroOnChanges: true # Option to prevent the workflow from failing
# Lint
- run: npm run lint
# Test
- run: npm run test
# Run Lighthouse audit (from any push)
- name: Performance Audit with Lighthouse CI
if: github.event_name == 'push'
run: npm run performance
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
# Check Changelog
- run: npm run check
- name: Validate no changes to tracked files
run: |
echo print files with changes:
git diff-index --ignore-space-at-eol --stat HEAD
echo exit with error if there are changes.
git diff-index --quiet --ignore-space-at-eol --stat HEAD
# Release
- name: Set Git User
if: startsWith(github.ref, 'refs/heads/main')
run: |
git config --global user.name "${{ env.GITHUB_SERVICE_USER }}"
git config --global user.email "${{ env.GITHUB_SERVICE_EMAIL }}"
# Update package versions, tag, and publish to npm (only from main)
- name: Beachball publish
if: startsWith(github.ref, 'refs/heads/main')
env:
NPM_SECRET_TOKEN: ${{ secrets.NPM_TOKEN }}
NUGET_SECRET_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: npm run invoke-publish
pages:
needs: build
if: startsWith(github.ref, 'refs/heads/main')
runs-on: ubuntu-22.04
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1