-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (166 loc) · 5.84 KB
/
check-typescript-projects.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Check TypeScript projects
on:
workflow_dispatch:
schedule:
- cron: '5 4 * * 1'
push:
branches:
- main
paths:
- '.github/workflows/check-typescript-projects.yml'
- '.nvmrc'
- 'projects/**/*'
pull_request:
branches:
- main
paths:
- '.github/workflows/check-typescript-projects.yml'
- '.nvmrc'
- 'projects/**/*'
jobs:
build_maxgraph_dev_package:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: 'maxGraph/maxGraph'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm install
- name: Build package
working-directory: packages/core
run: npm pack
- name: Upload npm package
uses: actions/upload-artifact@v3
with:
name: maxgraph-npm-package
path: |
packages/core/maxgraph-core-*.tgz
build_projects:
runs-on: ubuntu-22.04
needs: [build_maxgraph_dev_package]
strategy:
# don't cancel running jobs even if one fails
fail-fast: false
matrix:
project:
- lit-ts
- parcel-ts
- rollup-ts
- sveltekit-ts
- vitejs-ts
npm-package: ['release', 'development']
steps:
- name: Download the maxgraph npm package
if: ${{ matrix.npm-package == 'development' }}
id: 'download'
uses: actions/download-artifact@v3
with:
name: maxgraph-npm-package
path: ${{github.workspace}}/../maxgraph-npm-package
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
install-command: npm ci --prefer-offline --audit false --ignore-scripts
- name: Install maxgraph development npm package
if: ${{ matrix.npm-package == 'development' }}
# use wildcard as the file contains the version, and we don't know it
run: npm install ${{steps.download.outputs.download-path}}/maxgraph-core*.tgz
- name: Build project
run: npm run build -w projects/${{matrix.project}}
- name: Upload project archive
if: ${{ matrix.npm-package == 'release' }}
uses: actions/upload-artifact@v3
with:
name: ${{matrix.project}}
path: ${{github.workspace}}/projects/${{matrix.project}}/dist
# bundle everything in a single bundle + create home page
create_all-in-one_artifact:
runs-on: ubuntu-22.04
needs: 'build_projects'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: tmp
- name: Display structure of downloaded files after removing maxgraph-npm-package
run: |
rm -rf maxgraph-npm-package
ls -lhR
working-directory: tmp
- name: Build the final directories layout
run: |
mkdir -p build
cp -R tmp/* build
- name: List projects that will be referenced in the home page
id: list_projects
run: |
# for the ls option, see https://serverfault.com/a/1095912
echo "projects_path=$(ls -xw0 build/)" >> $GITHUB_OUTPUT
- name: Create the home page
uses: actions/github-script@v6
env:
PROJECTS_PATH: ${{ steps.list_projects.outputs.projects_path }}
with:
script: |
const {PROJECTS_PATH} = process.env;
const projectsListing = PROJECTS_PATH.split(' ').filter(name => name.trim() !== '').map(name => `<li><a href="${name}/index.html" target="_blank">${name}</a></li>`).join('\n');
let htmlContent = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Examples of maxGraph projects</title>
</head>
<body>
<h1>Examples of <code>maxGraph</code> projects</h1>
<p>
Projects built using the <a href="https://github.com/maxGraph/maxGraph/releases/latest" target="_blank">latest released version</a> of <code>maxGraph</code>
<ul>
${projectsListing}
</ul>
</body>
</html>
`
console.info('Generated page', htmlContent);
// Create the file
require('fs').writeFileSync('build/index.html', htmlContent);
- name: Display the final structure of files
run: |
ls -lhR build
- name: Upload artifact not for GitHub Pages
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') != 'true'
uses: actions/upload-artifact@v3
with:
name: all-typescript-projects-${{github.sha}}
path: build
- name: Upload artifact for GitHub Pages
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/upload-pages-artifact@v2
with:
path: build
deploy_gh_pages:
needs: create_all-in-one_artifact
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch' ) && github.event.ref == 'refs/heads/main'
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: read
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2