-
-
Notifications
You must be signed in to change notification settings - Fork 15
152 lines (133 loc) · 5.37 KB
/
Copy pathdeploy.yml
File metadata and controls
152 lines (133 loc) · 5.37 KB
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
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy Docs and ESPHome Firmware to Pages
on:
workflow_dispatch:
push:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false
jobs:
build-docs:
name: Build VitePress docs
uses: ./.github/workflows/build-docs.yml
prepare-release:
runs-on: ubuntu-latest
name: Prepare release data
outputs:
release_summary: ${{ steps.generate-summary.outputs.summary }}
release_url: ${{ steps.generate-summary.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate Release Data
id: generate-summary
run: |
GITHUB_REF_NAME=${{ github.ref_name }}
SHA=${{ github.sha }}
CHANGELOG_FILE="docs/en/changelog/firmware.md"
VERSION=$(awk '/project:/, /version:/' firmware/base.yaml | grep 'version:' | awk '{print $2}' | sed 's/[",]//g')
if [[ "${GITHUB_REF_NAME}" == "dev" ]] || [[ "${GITHUB_REF_NAME}" == dev* ]]; then
URL="https://dev.doorman.azon.ai/changelog/firmware"
else
URL="https://doorman.azon.ai/changelog/firmware"
fi
# Extract content from the section matching the version
RELEASE_BLOCK=$(awk -v version="## $VERSION" '
$0 ~ "^"version {flag=1; next}
/^## / && $0 != version {flag=0}
flag
' "$CHANGELOG_FILE")
if [[ "${GITHUB_REF_NAME}" != "master" ]]; then
RELEASE_BLOCK=$(echo "$RELEASE_BLOCK" | sed 's/doorman\.azon\.ai/dev.doorman.azon.ai/g')
fi
# Reduce heading levels safely using placeholders
RELEASE_BLOCK=$(echo "$RELEASE_BLOCK" | \
sed -e 's/^#### /<h4>/' \
-e 's/^### /<h3>/' \
-e 's/^## /<h2>/')
# Replace placeholders with the reduced heading levels
RELEASE_BLOCK=$(echo "$RELEASE_BLOCK" | \
sed -e 's/<h4>/### /' \
-e 's/<h3>/## /' \
-e 's/<h2>/# /')
# Write the clean summary to the output file without extra escaping
echo "url=$URL" >> $GITHUB_OUTPUT
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_BLOCK" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
build-webserver:
name: Build Webserver JS Bundle
uses: ./.github/workflows/build-webserver.yml
build-firmware:
name: Build ${{ matrix.chip }} ${{ matrix.variant }} (${{ matrix.integration }})
uses: ./.github/workflows/build-esphome.yml
needs: [prepare-release, build-webserver]
strategy:
matrix:
chip: [esp32, esp32-s3, esp32-s3-quad]
variant: [standard, nuki-bridge]
integration: [ha, mqtt, homekit, custom]
exclude:
# MQTT and HomeKit are incompatible with Nuki Bridge
- variant: nuki-bridge
integration: mqtt
- variant: nuki-bridge
integration: homekit
with:
files: firmware/configurations/${{ matrix.chip }}.${{ matrix.integration }}.${{ matrix.variant }}.${{ github.ref_name == 'master' && 'master' || 'dev' }}.yaml
name: Doorman ${{ matrix.variant == 'nuki-bridge' && 'Nuki-Bridge' || 'Standard' }} for ${{ matrix.integration == 'ha' && 'Home Assistant' || matrix.integration == 'mqtt' && 'MQTT' || matrix.integration == 'homekit' && 'HomeKit' || matrix.integration == 'custom' && 'Custom Integration' || matrix.integration }}
esphome_version: ${{ github.ref_name == 'master' && 'latest' || 'dev' }}
directory_name: ${{ matrix.chip }}.${{ matrix.integration }}.${{ matrix.variant }}
summary: ${{ needs.prepare-release.outputs.release_summary }}
url: ${{ needs.prepare-release.outputs.release_url }}
# Bundle all assets for Pages
bundle-assets:
name: Create asset bundle
uses: ./.github/workflows/bundle-assets.yml
needs: [build-docs, build-firmware, build-webserver]
# Deployment job
deploy-pages:
if: github.ref_name == 'master'
name: Deploy to Github Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: [bundle-assets]
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-dev:
if: startsWith(github.ref_name, 'dev')
name: Deploy to Dev Server
environment:
name: dev.doorman.azon.ai
url: "https://dev.doorman.azon.ai/"
needs: [bundle-assets]
runs-on: ubuntu-latest
steps:
- name: Download Assets
uses: actions/download-artifact@v6
with:
name: asset-bundle
path: output
- name: Deploy via SSH
uses: SamKirkland/web-deploy@v1
with:
target-server: dev.doorman.azon.ai
remote-user: ${{ secrets.AZON_USERNAME }}
private-ssh-key: ${{ secrets.AZON_SSH_KEY }}
source-path: ./output/
destination-path: ${{ secrets.AZON_PATH }}
ssh-port: ${{ secrets.AZON_SSH_PORT }}