Skip to content

Commit 9951b77

Browse files
authored
Add autoupdate frontend workflow (#133)
* Add autoupdate frontend workflow * Improve update_frontend
1 parent eed4d37 commit 9951b77

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/update_frontend.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
LANDING_PAGE_VERSION=$(cat .ha-frontend-version)
27+
LATEST_VERSION=${{ steps.latest_frontend_version.outputs.latest_tag }}
28+
echo "LANDING_PAGE_VERSION=$LANDING_PAGE_VERSION" >> $GITHUB_ENV
29+
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
30+
if [[ ! "$LANDING_PAGE_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+
run: |
38+
PR=$(gh pr list --state open --base main --json title --search "Autoupdate frontend to version $LATEST_VERSION")
39+
if [[ "$PR" != "[]" ]]; then
40+
echo "Skipping - There is already a PR open for version $LATEST_VERSION"
41+
echo "skip=true" >> $GITHUB_OUTPUT
42+
fi
43+
create-pr:
44+
runs-on: ubuntu-latest
45+
needs: check-version
46+
if: needs.check-version.outputs.skip != 'true'
47+
steps:
48+
- name: Clear www folder
49+
run: |
50+
rm -rf rootfs/usr/share/www/*
51+
- name: Update version file
52+
run: |
53+
echo "${{ needs.check-version.outputs.latest_tag }}" > .ha-frontend-version
54+
- name: Download release assets
55+
uses: robinraju/release-downloader@v1
56+
with:
57+
repository: 'home-assistant/frontend'
58+
tag: ${{ needs.check-version.outputs.latest_tag }}
59+
fileName: home_assistant_frontend_landingpage-${{ needs.check-version.outputs.latest_tag }}.tar.gz
60+
extract: true
61+
out-file-path: rootfs/usr/share/www/
62+
- name: Create PR
63+
uses: peter-evans/create-pull-request@v7
64+
with:
65+
commit-message: "Autoupdate frontend to version ${{ needs.check-version.outputs.latest_tag }}"
66+
branch: autoupdate-frontend
67+
base: main
68+
sign-commits: true
69+
title: "Autoupdate frontend to version ${{ needs.check-version.outputs.latest_tag }}"

.ha-frontend-version

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

0 commit comments

Comments
 (0)