-
Notifications
You must be signed in to change notification settings - Fork 4
141 lines (120 loc) · 4.17 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
# Workflow to build and test node.js app with install, build, and test scripts.
# The workflow also expects that the app will have a github pages built using build
# that will live under /docs, and so also automatically adds and commits /docs
# whenever "release:" prefixed commits are made.
name: main
# Any event listed can trigger build/test; only push triggers docs build and new tag
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Manual run from GitHub UI
workflow_dispatch:
# Wednesdays at 0400
# schedule:
# - cron: '0 4 * * 3'
permissions:
pages: write
contents: write
jobs:
build-and-test:
timeout-minutes: 10
runs-on: ubuntu-latest
environment: build-fonts
strategy:
matrix:
node-version: [lts/*]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
env:
# Suppresses annoying warning https://github.com/cypress-io/cypress/issues/15679
TERM: xterm
# Suppress Cypress installation progress messages
CI: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install
run: npm ci
- name: Build
run: npm run build --if-present
- name: Install Cypress
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Test using Cypress - E2E
uses: cypress-io/github-action@v6
with:
# Test against the build we just created
start: npm run preview
config: baseUrl=http://localhost:4173/react-fontpicker
working-directory: packages/fontpicker
install: false
- name: Test using Cypress - Component
uses: cypress-io/github-action@v6
with:
component: true
working-directory: packages/fontpicker
install: false
- name: Test
run: npm run test
- name: Add GOOGLE_API_KEY
run: echo "${{secrets.GOOGLE_API_KEY}}" > packages/fontpicker/GOOGLE_API_KEY
- name: Restore font-cache
id: cache-font-restore
uses: actions/cache/restore@v4
with:
path: |
packages/fontpicker/font-cache
key: font-cache-${{ hashFiles('packages/fontpicker/scripts/75-google-fonts.txt') }}
- name: Build fontpicker-lite package
run: bash packages/fontpicker-lite/build-lite.sh
- name: Save font-cache
id: cache-font-save
uses: actions/cache/save@v4
with:
path: |
packages/fontpicker/font-cache
key: ${{ steps.cache-font-restore.outputs.cache-primary-key }}
- name: Test fontpicker-lite package
run: bash packages/fontpicker-lite/test-lite.sh
# For push events only, rebuild docs page and create a tag.
# Ideally this would be in a separate job, but jobs execute on different runners which means
# some duplication with above.
- name: Test is release
if: startsWith(github.event.head_commit.message, 'release:') && github.event_name == 'push'
id: isRelease
run: |
echo "value=true" >> $GITHUB_OUTPUT
- name: Get release version string
if: steps.isRelease.outputs.value
id: getVersion
env:
MESSAGE: ${{ github.event.head_commit.message }}
run: |
VALUE=$(echo "${MESSAGE}" | sed 's/release://' | sed 's/[[:space:]]*//g')
echo "value=${VALUE}" >> $GITHUB_OUTPUT
- name: Commit /docs
if: steps.isRelease.outputs.value
# EndBug/add-and-commit@v9.1.1
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5
with:
default_author: github_actions
add: 'packages/fontpicker/docs'
message: "docs: rebuild for release ${{ steps.getVersion.outputs.value }}"
- name: Create tag
if: steps.isRelease.outputs.value
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.getVersion.outputs.value }}",
sha: context.sha
})