Update generated documentation #1287
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update generated documentation | |
on: | |
schedule: | |
- cron: "0 16 * * *" | |
workflow_dispatch: | |
inputs: | |
forced: | |
description: "Force regeneration even if the Zigbee2MQTT versions did not change" | |
required: false | |
default: false | |
type: boolean | |
jobs: | |
docs: | |
runs-on: ubuntu-latest | |
env: | |
versions_file: src/docgen/versions.ts | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Determine Zigbee2MQTT version | |
id: version | |
run: | | |
echo "updated=0" >> $GITHUB_OUTPUT | |
Z2M_VERSION=$(npm view zigbee2mqtt@latest version) | |
echo "z2m=$Z2M_VERSION" >> $GITHUB_OUTPUT | |
HERDSMAN_VERSION=$(npm view "zigbee2mqtt@$Z2M_VERSION" dependencies.zigbee-herdsman-converters) | |
echo "herdsman=$HERDSMAN_VERSION" >> $GITHUB_OUTPUT | |
{ | |
echo "// GENERATED FILE: DO NOT EDIT MANUALLY!" | |
echo "const version_zigbee2mqtt = '$Z2M_VERSION';" | |
echo "const version_herdsman_converters = '$HERDSMAN_VERSION';" | |
echo "export { version_zigbee2mqtt, version_herdsman_converters };" | |
} > ${{ env.versions_file }} | |
git diff --exit-code -s ${{ env.versions_file }} || echo "updated=1" >> $GITHUB_OUTPUT | |
- name: Install regular dependencies and zigbee-herdsman-converters | |
if: ${{ steps.version.outputs.updated == 1 || inputs.forced }} | |
run: | | |
npm ci | |
npm i --no-save zigbee-herdsman-converters@${{ steps.version.outputs.herdsman }} | |
- name: Generate documentation | |
id: docs | |
if: ${{ steps.version.outputs.updated == 1 || inputs.forced }} | |
run: | | |
echo "updated=0" >> $GITHUB_OUTPUT | |
node_modules/.bin/ts-node src/docgen/docgen.ts | |
git diff --exit-code -s docs ||echo "updated=1" >> $GITHUB_OUTPUT | |
- uses: actions/create-github-app-token@v1 | |
id: pr-token | |
with: | |
app-id: ${{ secrets.PR_APP_ID }} | |
private-key: ${{ secrets.PR_APP_SECRET }} | |
- name: Open/update PR | |
if: ${{ steps.docs.outputs.updated == 1 }} | |
id: cpr | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ steps.pr-token.outputs.token }} | |
assignees: itavero | |
commit-message: "Docs generated based on zigbee-herdsman-converters v${{ steps.version.outputs.herdsman }}" | |
branch: update-device-docs | |
delete-branch: true | |
title: "Update device documentation (zigbee-herdsman-converters ${{ steps.version.outputs.herdsman }})" | |
body: |- | |
Documentation has been automatically regenerated, because a new version of :bee: Zigbee2MQTT and/or zigbee-herdsman-converters | |
was detected or because a forced update was requested. | |
Based on: | |
- Zigbee2MQTT **v${{ steps.version.outputs.z2m }}** | |
- zigbee-herdsman-converters **v${{ steps.version.outputs.herdsman }}** | |
:robot: *I am a bot. This action was performed automatically.* |