Skip to content

Commit 65e3a7f

Browse files
committed
ci: automate GitHub Pages deployment via GitHub Actions
- Added `.github/workflows/deploy.yml` to automatically build and deploy the project to the `gh-pages` branch on every push to `master`. - Automated the transformation of `examples/charts.html` into the root `index.html` with correct asset paths. - Restored Google Analytics tracking code (UA-53037324-1) in `examples/charts.template.html`. - Updated `bower.json` dependencies to require AngularJS 1.8.x and Chart.js 2.x for consistency. - Removed unused `testatic` development dependency.
1 parent bfcef41 commit 65e3a7f

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: 'npm'
19+
20+
- name: Install dependencies
21+
run: npm install
22+
23+
- name: Build project
24+
run: npm run build
25+
26+
- name: Update examples
27+
run: npx gulp update
28+
29+
- name: Prepare deployment
30+
run: |
31+
mkdir -p deploy/examples
32+
mkdir -p deploy/node_modules
33+
cp -r dist deploy/
34+
cp -r examples/* deploy/examples/
35+
# Copy only required node_modules to keep it small
36+
cp -r node_modules/angular deploy/node_modules/
37+
cp -r node_modules/chart.js deploy/node_modules/
38+
cp -r node_modules/angular-bootstrap deploy/node_modules/
39+
cp -r node_modules/rainbow-code deploy/node_modules/
40+
cp -r node_modules/font-awesome deploy/node_modules/
41+
cp -r node_modules/bootstrap deploy/node_modules/
42+
# Move charts.html to index.html and fix paths
43+
sed 's|../node_modules/|node_modules/|g' examples/charts.html | sed 's|../angular-chart.js|dist/angular-chart.js|g' > deploy/index.html
44+
45+
- name: Deploy to gh-pages
46+
uses: peaceiris/actions-gh-pages@v4
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: ./deploy

examples/charts.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,5 +697,14 @@ <h1>Mixed type charts</h1>
697697
<script src="../angular-chart.js"></script>
698698
<script src="smoothscroll.min.js"></script>
699699
<script src="app.js"></script>
700+
<script>
701+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
702+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
703+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
704+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
705+
706+
ga('create', 'UA-53037324-1', 'auto');
707+
ga('send', 'pageview');
708+
</script>
700709
</body>
701710
</html>

examples/charts.template.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,5 +697,14 @@ <h1>Mixed type charts</h1>
697697
<script src="../angular-chart.js"></script>
698698
<script src="smoothscroll.min.js"></script>
699699
<script src="app.js"></script>
700+
<script>
701+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
702+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
703+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
704+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
705+
706+
ga('create', 'UA-53037324-1', 'auto');
707+
ga('send', 'pageview');
708+
</script>
700709
</body>
701710
</html>

0 commit comments

Comments
 (0)