From 549e3c8d38e3b63fc65033f59cd1e8594fb10e06 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 01:49:56 +0000 Subject: [PATCH 1/7] [CI] add Github action to bump modules commit Version --- .github/workflows/bump-modules.yml | 45 ++++++++++++++++++++++++++++++ contrib/actions/update-modules.sh | 27 ++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/bump-modules.yml create mode 100755 contrib/actions/update-modules.sh diff --git a/.github/workflows/bump-modules.yml b/.github/workflows/bump-modules.yml new file mode 100644 index 00000000..cda16153 --- /dev/null +++ b/.github/workflows/bump-modules.yml @@ -0,0 +1,45 @@ +--- +name: "Update Modules base" + +on: + workflow_dispatch: + +permissions: + contents: write # so it can comment + pull-requests: write # so it can create pull requests + +jobs: + update-Modules: + runs-on: ubuntu-22.04 + env: + COMMIT_NAME: github-actions[bot] + COMMIT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com + steps: + - name: Clone Firmware + uses: actions/checkout@v4 + + - name: Get update branch name + id: branch-name + run: echo "branch-name=update-modules-${{ github.event.inputs.branch }}-$(date +%s)" >> $GITHUB_OUTPUT + + - name: Invoke update-modules + run: ./contrib/actions/update-modules.sh + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v6 + with: + title: '[Update] ${{ github.event.inputs.branch }} modules' + body: | + Update modules for ${{ github.event.inputs.branch }} branche + - Auto-generated by [create-pull-request][1] + + [1]: https://github.com/peter-evans/create-pull-request + commit-message: bump modules version + branch: ${{ steps.branch-name.outputs.branch-name }} + + - name: Check outputs + if: ${{ steps.cpr.outputs.pull-request-number }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file diff --git a/contrib/actions/update-modules.sh b/contrib/actions/update-modules.sh new file mode 100755 index 00000000..b956c447 --- /dev/null +++ b/contrib/actions/update-modules.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Die Datei, die die Repository-Informationen enthaelt +MODULES_FILE="modules" + +# Durchlaufe die Datei, um alle Repository-URLs und ihre entsprechenden Commit-Variablen zu finden +while IFS= read -r line; do + # ^|berpr fe, ob die Zeile eine Repository-URL ist + if [[ "$line" == "PACKAGES_"*"_REPO="* ]]; then + # Extrahiere den Repository-Namen und die URL + REPO_NAME=$(echo "$line" | cut -d '=' -f 1) + REPO_URL=$(echo "$line" | cut -d '=' -f 2-) + + # Den neuesten Commit für das Repository abrufen + NEW_COMMIT=$(git ls-remote "$REPO_URL" | grep -oE '[0-9a-f]{40}' | head -n1) + + # Überprüfen, ob ein neuer Commit gefunden wurde + if [ -n "$NEW_COMMIT" ]; then + # Den Wert des Commits in der Datei aktualisieren + COMMIT_LINE=$(grep -n "${REPO_NAME/_REPO/_COMMIT}" "$MODULES_FILE" | cut -d ':' -f 1) + sed -i "${COMMIT_LINE}s/.*/${REPO_NAME/_REPO/_COMMIT}=$NEW_COMMIT/" "$MODULES_FILE" + echo "Der Wert von ${REPO_NAME/_REPO/_COMMIT} wurde auf den neuesten Commit ($NEW_COMMIT) aktualisiert." + else + echo "Fehler: Der neueste Commit f r $REPO_NAME konnte nicht abgerufen werden." + fi + fi +done < "$MODULES_FILE" \ No newline at end of file From b148ca4c2e30c138555df8d0a2480aa9f01b8198 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 01:54:17 +0000 Subject: [PATCH 2/7] add newline and remove spaces --- .github/workflows/bump-modules.yml | 8 ++++---- contrib/actions/update-modules.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump-modules.yml b/.github/workflows/bump-modules.yml index cda16153..7c176b34 100644 --- a/.github/workflows/bump-modules.yml +++ b/.github/workflows/bump-modules.yml @@ -3,7 +3,7 @@ name: "Update Modules base" on: workflow_dispatch: - + permissions: contents: write # so it can comment pull-requests: write # so it can create pull requests @@ -24,7 +24,7 @@ jobs: - name: Invoke update-modules run: ./contrib/actions/update-modules.sh - + - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v6 @@ -37,9 +37,9 @@ jobs: [1]: https://github.com/peter-evans/create-pull-request commit-message: bump modules version branch: ${{ steps.branch-name.outputs.branch-name }} - + - name: Check outputs if: ${{ steps.cpr.outputs.pull-request-number }} run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/contrib/actions/update-modules.sh b/contrib/actions/update-modules.sh index b956c447..930ce4d6 100755 --- a/contrib/actions/update-modules.sh +++ b/contrib/actions/update-modules.sh @@ -24,4 +24,4 @@ while IFS= read -r line; do echo "Fehler: Der neueste Commit f r $REPO_NAME konnte nicht abgerufen werden." fi fi -done < "$MODULES_FILE" \ No newline at end of file +done < "$MODULES_FILE" From 994c4581962b59e31c3d8689e5ffca67d195f7b4 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 02:07:42 +0000 Subject: [PATCH 3/7] fix shellcheck we need to read and write to the same file --- contrib/actions/update-modules.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/actions/update-modules.sh b/contrib/actions/update-modules.sh index 930ce4d6..db8b0b47 100755 --- a/contrib/actions/update-modules.sh +++ b/contrib/actions/update-modules.sh @@ -17,11 +17,14 @@ while IFS= read -r line; do # Überprüfen, ob ein neuer Commit gefunden wurde if [ -n "$NEW_COMMIT" ]; then # Den Wert des Commits in der Datei aktualisieren + # shellcheck disable=SC2094 COMMIT_LINE=$(grep -n "${REPO_NAME/_REPO/_COMMIT}" "$MODULES_FILE" | cut -d ':' -f 1) + # shellcheck disable=SC2094 sed -i "${COMMIT_LINE}s/.*/${REPO_NAME/_REPO/_COMMIT}=$NEW_COMMIT/" "$MODULES_FILE" echo "Der Wert von ${REPO_NAME/_REPO/_COMMIT} wurde auf den neuesten Commit ($NEW_COMMIT) aktualisiert." else echo "Fehler: Der neueste Commit f r $REPO_NAME konnte nicht abgerufen werden." fi fi +# shellcheck disable=SC2094 done < "$MODULES_FILE" From 5c9bb11f9753a43279de5a2cea36260ce6b8c954 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 02:09:34 +0000 Subject: [PATCH 4/7] move shellchecck disbale --- contrib/actions/update-modules.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/actions/update-modules.sh b/contrib/actions/update-modules.sh index db8b0b47..1ad5bec7 100755 --- a/contrib/actions/update-modules.sh +++ b/contrib/actions/update-modules.sh @@ -4,6 +4,7 @@ MODULES_FILE="modules" # Durchlaufe die Datei, um alle Repository-URLs und ihre entsprechenden Commit-Variablen zu finden +# shellcheck disable=SC2094 while IFS= read -r line; do # ^|berpr fe, ob die Zeile eine Repository-URL ist if [[ "$line" == "PACKAGES_"*"_REPO="* ]]; then @@ -26,5 +27,4 @@ while IFS= read -r line; do echo "Fehler: Der neueste Commit f r $REPO_NAME konnte nicht abgerufen werden." fi fi -# shellcheck disable=SC2094 done < "$MODULES_FILE" From 3060195ad39029b3eba473385480e8d98a9c494a Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 02:12:44 +0000 Subject: [PATCH 5/7] add ignores for new workflow --- .github/workflows/firmware.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml index 7d9ad33d..b6b6cf09 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/firmware.yml @@ -12,7 +12,9 @@ on: - '.github/ISSUE_TEMPLATE' - '.github/*.yml' - '.github/workflows/backport.yml' + - '.github/workflows/bump-modules.yml' - 'contrib/sign.sh' + - 'contrib/actions/update-modules.sh' jobs: generate_target_matrix: From 92b67a09dc55ad5cde11e1abdedbc890def5f48a Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 20:37:37 +0200 Subject: [PATCH 6/7] using defaults dont need this envs --- .github/workflows/bump-modules.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/bump-modules.yml b/.github/workflows/bump-modules.yml index 7c176b34..dadd2b29 100644 --- a/.github/workflows/bump-modules.yml +++ b/.github/workflows/bump-modules.yml @@ -11,9 +11,6 @@ permissions: jobs: update-Modules: runs-on: ubuntu-22.04 - env: - COMMIT_NAME: github-actions[bot] - COMMIT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com steps: - name: Clone Firmware uses: actions/checkout@v4 From 91c4f2ecca05fa92b19915b2f1cf3d1c40fd82e0 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Apr 2024 20:39:34 +0200 Subject: [PATCH 7/7] Update update-modules.sh --- contrib/actions/update-modules.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/actions/update-modules.sh b/contrib/actions/update-modules.sh index 1ad5bec7..68f3f29a 100755 --- a/contrib/actions/update-modules.sh +++ b/contrib/actions/update-modules.sh @@ -6,7 +6,7 @@ MODULES_FILE="modules" # Durchlaufe die Datei, um alle Repository-URLs und ihre entsprechenden Commit-Variablen zu finden # shellcheck disable=SC2094 while IFS= read -r line; do - # ^|berpr fe, ob die Zeile eine Repository-URL ist + # Überprüfe, ob die Zeile eine Repository-URL ist if [[ "$line" == "PACKAGES_"*"_REPO="* ]]; then # Extrahiere den Repository-Namen und die URL REPO_NAME=$(echo "$line" | cut -d '=' -f 1)