Skip to content

Commit

Permalink
Bundle Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Aug 14, 2024
1 parent e3acde1 commit c966dfd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 163 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build Vitepress Docs

on:
workflow_call:

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Extract version from base.yaml
run: |
VERSION=$(awk '/project:/, /version:/' firmware/base.yaml | grep 'version:' | awk '{print $2}' | sed 's/[",]//g')
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Update package.json version
if: github.ref == 'refs/heads/master'
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" package.json
- name: Update package.json version
if: github.ref != 'refs/heads/master'
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}-dev\"/" package.json
- name: Install dependencies
run: npm ci

- name: Build with VitePress
run: npm run docs:build

- name: Upload VitePress artifact
uses: actions/upload-artifact@v4
with:
name: vitepress-docs
path: docs/.vitepress/dist
116 changes: 0 additions & 116 deletions .github/workflows/deploy-pages-dev.yml

This file was deleted.

80 changes: 34 additions & 46 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
name: Deploy Docs and ESPHome Firmware to Pages

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches: [master]

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

jobs:
# Build job
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Extract version from base.yaml
run: |
VERSION=$(awk '/project:/, /version:/' firmware/base.yaml | grep 'version:' | awk '{print $2}' | sed 's/[",]//g')
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Update package.json version
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" package.json
- name: Install dependencies
run: npm ci

- name: Build with VitePress
run: npm run docs:build

- name: Upload VitePress artifact
uses: actions/upload-artifact@v4
with:
name: vitepress-docs
path: docs/.vitepress/dist
name: Build Docs
uses: ./.github/workflows/build-docs.yml

build-doorman-stock-firmware:
name: Build Doorman Stock Firmware
Expand Down Expand Up @@ -115,19 +75,47 @@ jobs:
path: output/firmware/release

- name: Upload Pages artifact
if: github.ref == 'refs/heads/master'
uses: actions/upload-pages-artifact@v3
with:
path: output

- name: Upload Assets Bundle
if: github.ref != 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: asset-bundle
path: output

# Deployment job
deploy:
deploy-master:
if: github.ref == 'refs/heads/master'
name: Deploy to Github Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: [bundle-assets]
runs-on: ubuntu-latest
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4

deploy-dev:
if: github.ref != 'refs/heads/master'
name: Deploy to surge.sh
needs: [bundle-assets]
runs-on: ubuntu-latest
steps:
- name: Download Assets
uses: actions/download-artifact@v4
with:
name: asset-bundle
path: output

- uses: actions/setup-node@v4
with:
node-version: 20

- run: npm install -g surge
- run: surge output ${{ secrets.SURGE_DOMAIN }} --token ${{ secrets.SURGE_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/esphome-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
steps:
- uses: actions/checkout@v4

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

0 comments on commit c966dfd

Please sign in to comment.