Skip to content

Commit c966dfd

Browse files
committed
Bundle Workflow
1 parent e3acde1 commit c966dfd

File tree

4 files changed

+84
-163
lines changed

4 files changed

+84
-163
lines changed

.github/workflows/build-docs.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build Vitepress Docs
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build-docs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Setup Node
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 20
19+
cache: npm
20+
21+
- name: Setup Pages
22+
uses: actions/configure-pages@v4
23+
24+
- name: Extract version from base.yaml
25+
run: |
26+
VERSION=$(awk '/project:/, /version:/' firmware/base.yaml | grep 'version:' | awk '{print $2}' | sed 's/[",]//g')
27+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
28+
29+
- name: Update package.json version
30+
if: github.ref == 'refs/heads/master'
31+
run: |
32+
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" package.json
33+
34+
- name: Update package.json version
35+
if: github.ref != 'refs/heads/master'
36+
run: |
37+
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}-dev\"/" package.json
38+
39+
- name: Install dependencies
40+
run: npm ci
41+
42+
- name: Build with VitePress
43+
run: npm run docs:build
44+
45+
- name: Upload VitePress artifact
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: vitepress-docs
49+
path: docs/.vitepress/dist

.github/workflows/deploy-pages-dev.yml

Lines changed: 0 additions & 116 deletions
This file was deleted.

.github/workflows/deploy-pages.yml

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33
name: Deploy Docs and ESPHome Firmware to Pages
44

55
on:
6-
# Allows you to run this workflow manually from the Actions tab
76
workflow_dispatch:
8-
9-
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
10-
# using the `master` branch as the default branch.
117
push:
12-
branches: [master]
138

149
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1510
permissions:
@@ -24,44 +19,9 @@ concurrency:
2419
cancel-in-progress: false
2520

2621
jobs:
27-
# Build job
2822
build-docs:
29-
runs-on: ubuntu-latest
30-
steps:
31-
- name: Checkout
32-
uses: actions/checkout@v4
33-
with:
34-
fetch-depth: 0
35-
36-
- name: Setup Node
37-
uses: actions/setup-node@v4
38-
with:
39-
node-version: 20
40-
cache: npm
41-
42-
- name: Setup Pages
43-
uses: actions/configure-pages@v4
44-
45-
- name: Extract version from base.yaml
46-
run: |
47-
VERSION=$(awk '/project:/, /version:/' firmware/base.yaml | grep 'version:' | awk '{print $2}' | sed 's/[",]//g')
48-
echo "VERSION=${VERSION}" >> $GITHUB_ENV
49-
50-
- name: Update package.json version
51-
run: |
52-
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" package.json
53-
54-
- name: Install dependencies
55-
run: npm ci
56-
57-
- name: Build with VitePress
58-
run: npm run docs:build
59-
60-
- name: Upload VitePress artifact
61-
uses: actions/upload-artifact@v4
62-
with:
63-
name: vitepress-docs
64-
path: docs/.vitepress/dist
23+
name: Build Docs
24+
uses: ./.github/workflows/build-docs.yml
6525

6626
build-doorman-stock-firmware:
6727
name: Build Doorman Stock Firmware
@@ -115,19 +75,47 @@ jobs:
11575
path: output/firmware/release
11676

11777
- name: Upload Pages artifact
78+
if: github.ref == 'refs/heads/master'
11879
uses: actions/upload-pages-artifact@v3
11980
with:
12081
path: output
82+
83+
- name: Upload Assets Bundle
84+
if: github.ref != 'refs/heads/master'
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: asset-bundle
88+
path: output
12189

12290
# Deployment job
123-
deploy:
91+
deploy-master:
92+
if: github.ref == 'refs/heads/master'
93+
name: Deploy to Github Pages
12494
environment:
12595
name: github-pages
12696
url: ${{ steps.deployment.outputs.page_url }}
12797
needs: [bundle-assets]
128-
runs-on: ubuntu-latest
129-
name: Deploy
98+
runs-on: ubuntu-latest
13099
steps:
131100
- name: Deploy to GitHub Pages
132101
id: deployment
133-
uses: actions/deploy-pages@v4
102+
uses: actions/deploy-pages@v4
103+
104+
deploy-dev:
105+
if: github.ref != 'refs/heads/master'
106+
name: Deploy to surge.sh
107+
needs: [bundle-assets]
108+
runs-on: ubuntu-latest
109+
steps:
110+
- name: Download Assets
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: asset-bundle
114+
path: output
115+
116+
- uses: actions/setup-node@v4
117+
with:
118+
node-version: 20
119+
120+
- run: npm install -g surge
121+
- run: surge output ${{ secrets.SURGE_DOMAIN }} --token ${{ secrets.SURGE_TOKEN }}

.github/workflows/esphome-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
steps:
4949
- uses: actions/checkout@v4
5050

51-
- name: Update ESPHome project version
51+
- name: Change ESPHome project version to dev
5252
if: github.ref != 'refs/heads/master'
5353
run: |
5454
sed -i '/^ project:/,/^ platformio_options:/s/^ version: .*/ version: "'"$VERSION"'-dev"/' firmware/base.yaml

0 commit comments

Comments
 (0)