Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] add Github action to bump modules commit Version #405

Merged
merged 7 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/bump-modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
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
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 }}"
2 changes: 2 additions & 0 deletions .github/workflows/firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions contrib/actions/update-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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
# shellcheck disable=SC2094
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
# 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
done < "$MODULES_FILE"
Loading