Skip to content

Commit b07236b

Browse files
wendevlinagners
andauthored
Add frontend auto update workflow (#5501)
* Remove git submodule * Add frontend auto update workflow * Update .github/workflows/update_frontend.yml Co-authored-by: Stefan Agner <[email protected]> --------- Co-authored-by: Stefan Agner <[email protected]>
1 parent 5928a31 commit b07236b

File tree

5 files changed

+75
-32
lines changed

5 files changed

+75
-32
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Update frontend
2+
3+
on:
4+
schedule: # once a day
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-version:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
skip: ${{ steps.check_version.outputs.skip || steps.check_existing_pr.outputs.skip }}
13+
latest_tag: ${{ steps.latest_frontend_version.outputs.latest_tag }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Get latest frontend release
18+
id: latest_frontend_version
19+
uses: abatilo/[email protected]
20+
with:
21+
owner: home-assistant
22+
repo: frontend
23+
- name: Check if version is up to date
24+
id: check_version
25+
run: |
26+
SUPERVISOR_VERSION=$(cat .ha-frontend-version)
27+
LATEST_VERSION=${{ steps.latest_frontend_version.outputs.latest_tag }}
28+
echo "SUPERVISOR_VERSION=$SUPERVISOR_VERSION" >> $GITHUB_ENV
29+
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
30+
if [[ ! "$SUPERVISOR_VERSION" < "$LATEST_VERSION" ]]; then
31+
echo "Frontend version is up to date"
32+
echo "skip=true" >> $GITHUB_OUTPUT
33+
fi
34+
- name: Check if there is no open PR with this version
35+
if: steps.check_version.outputs.skip != 'true'
36+
id: check_existing_pr
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
run: |
40+
PR=$(gh pr list --state open --base main --json title --search "Autoupdate frontend to version $LATEST_VERSION")
41+
if [[ "$PR" != "[]" ]]; then
42+
echo "Skipping - There is already a PR open for version $LATEST_VERSION"
43+
echo "skip=true" >> $GITHUB_OUTPUT
44+
fi
45+
create-pr:
46+
runs-on: ubuntu-latest
47+
needs: check-version
48+
if: needs.check-version.outputs.skip != 'true'
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
- name: Clear www folder
53+
run: |
54+
rm -rf supervisor/api/panel/*
55+
- name: Update version file
56+
run: |
57+
echo "${{ needs.check-version.outputs.latest_tag }}" > .ha-frontend-version
58+
- name: Download release assets
59+
uses: robinraju/release-downloader@v1
60+
with:
61+
repository: 'home-assistant/frontend'
62+
tag: ${{ needs.check-version.outputs.latest_tag }}
63+
fileName: home_assistant_frontend_supervisor-${{ needs.check-version.outputs.latest_tag }}.tar.gz
64+
extract: true
65+
out-file-path: supervisor/api/panel/
66+
- name: Create PR
67+
uses: peter-evans/create-pull-request@v7
68+
with:
69+
commit-message: "Autoupdate frontend to version ${{ needs.check-version.outputs.latest_tag }}"
70+
branch: autoupdate-frontend
71+
base: main
72+
draft: true
73+
sign-commits: true
74+
title: "Autoupdate frontend to version ${{ needs.check-version.outputs.latest_tag }}"

.gitmodules

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

.ha-frontend-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20241127.8

home-assistant-polymer

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/update-frontend.sh

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

0 commit comments

Comments
 (0)