From c09bc14035c38c5d322e7433595483361d6846a8 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Thu, 28 Mar 2024 23:05:21 +0100
Subject: [PATCH] github: add action for OpenWrt base update (#3235)

Create a GitHub action to automatically create updates to the OpenWrt
base-version on manual run.

This allows to create base-modules updates where Gluon patches did not
change from the GitHub UI.

Skip PR creation. Automatically created PRs do not invoke subsequent
actions, thus not creating build-tests.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 .github/workflows/bump-gluon.yml | 51 ++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 .github/workflows/bump-gluon.yml

diff --git a/.github/workflows/bump-gluon.yml b/.github/workflows/bump-gluon.yml
new file mode 100644
index 000000000..163b1974f
--- /dev/null
+++ b/.github/workflows/bump-gluon.yml
@@ -0,0 +1,51 @@
+---
+name: "Update OpenWrt base"
+
+on:
+  workflow_dispatch:
+    inputs:
+      branch:
+        description: "Branch to create update for"
+        required: true
+        default: "master"
+
+jobs:
+  update-openwrt:
+    runs-on: ubuntu-22.04
+    env:
+      COMMIT_NAME: Gluon CI Bot
+      COMMIT_EMAIL: bot@freifunk-gluon.github.io
+    steps:
+      - name: Clone Gluon
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.inputs.branch }}
+      
+      - name: Configure Git User and E-Mail
+        run: git config --global user.name "${{ env.COMMIT_NAME }}" && git config --global user.email "${{ env.COMMIT_EMAIL }}"
+      
+      - name: Get update branch name
+        id: branch-name
+        run: echo "branch-name=update-openwrt-${{ github.event.inputs.branch }}-$(date +%s)" >> $GITHUB_OUTPUT
+
+      - name: Link example Site
+        run: ln -s docs/site-example site
+      
+      - name: Invoke update-modules
+        run: make update-modules
+      
+      - name: Refresh patches
+        run: make refresh-patches
+      
+      - name: Check if unstaged commits exist
+        run: git diff --exit-code || echo "::warning::Patches need a manual refresh"
+      
+      - name: Checkout individual branch name
+        run: git checkout -b ${{ steps.branch-name.outputs.branch-name }}
+      
+      - name: Push branch
+        run: git push origin HEAD
+
+      - name: Emit PR creation message
+        run:
+          echo "::notice::Create pull-request at https://github.com/${{ github.repository }}/compare/${{ github.event.inputs.branch }}...${{ steps.branch-name.outputs.branch-name }}?quick_pull=1"
-- 
GitLab