Tilføj workflow til automatisk synkronisering af submodule-pointer - #1
Open
SSogaard94 wants to merge 1 commit into
Open
Tilføj workflow til automatisk synkronisering af submodule-pointer#1SSogaard94 wants to merge 1 commit into
SSogaard94 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow that, on every push to main in bc-code-intelligence, discovers all non-archived repos in the kollabdk org consuming this repo as a git submodule and bumps the submodule pointer to the latest commit. Discovery is dynamic (no hardcoded list), and updates run in parallel (max 10) with fail-fast: false. An alternative PR-based flow is kept as commented-out YAML.
Changes:
- New
discoverjob enumerates org repos viagh repo listand inspects each repo's.gitmodulesto find consumers. - New
updatematrix job clones each consumer, advances thebc-code-intelligencesubmodule togithub.sha, commits, and pushes directly tomain. - Documents required
ORG_SYNC_TOKENsecret and provides commented-out PR-creation alternative.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+75
to
+82
| # Peg submodulet på den nye commit | ||
| git submodule update --init bc-code-intelligence | ||
| cd bc-code-intelligence | ||
| git fetch origin | ||
| git checkout $NEW_SHA | ||
| cd .. | ||
|
|
||
| git add bc-code-intelligence |
Comment on lines
+67
to
+97
| git clone --depth=1 \ | ||
| https://x-access-token:$GH_TOKEN@github.com/kollabdk/${{ matrix.repo }}.git \ | ||
| target | ||
|
|
||
| cd target | ||
| git config user.name "kollab-ai-sync[bot]" | ||
| git config user.email "ai-sync@kollab.dk" | ||
|
|
||
| # Peg submodulet på den nye commit | ||
| git submodule update --init bc-code-intelligence | ||
| cd bc-code-intelligence | ||
| git fetch origin | ||
| git checkout $NEW_SHA | ||
| cd .. | ||
|
|
||
| git add bc-code-intelligence | ||
|
|
||
| # Spring over hvis der ikke er nogen ændring | ||
| if git diff --staged --quiet; then | ||
| echo "Ingen ændring nødvendig i ${{ matrix.repo }}, springer over." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git commit -m "chore: opdater bc-code-intelligence submodule til seneste version [skip ci]" | ||
|
|
||
| # ----------------------------------------------------------- | ||
| # VALG: Direkte commit eller Pull Request? | ||
| # | ||
| # AKTIV: Direkte commit til main | ||
| # ----------------------------------------------------------- | ||
| git push origin main |
Comment on lines
+90
to
+110
| git commit -m "chore: opdater bc-code-intelligence submodule til seneste version [skip ci]" | ||
|
|
||
| # ----------------------------------------------------------- | ||
| # VALG: Direkte commit eller Pull Request? | ||
| # | ||
| # AKTIV: Direkte commit til main | ||
| # ----------------------------------------------------------- | ||
| git push origin main | ||
|
|
||
| # ----------------------------------------------------------- | ||
| # ALTERNATIV: Opret en Pull Request i stedet for direkte push. | ||
| # Kommenter linjen ovenfor ud og fjern kommenteringen nedenfor. | ||
| # ----------------------------------------------------------- | ||
| # BRANCH="update-bc-intelligence-$(date +%Y%m%d-%H%M)" | ||
| # git checkout -b $BRANCH | ||
| # git push origin $BRANCH | ||
| # gh pr create \ | ||
| # --title "Opdater bc-code-intelligence submodule" \ | ||
| # --body "Automatisk opdatering til nyeste AI-personas og workflows fra bc-code-intelligence." \ | ||
| # --base main \ | ||
| # --head $BRANCH |
Comment on lines
+25
to
+44
| # Hent alle ikke-arkiverede repos i org'en (ingen hardkodet liste!) | ||
| ALL_REPOS=$(gh repo list kollabdk --limit 1000 --json name,isArchived \ | ||
| --jq '[.[] | select(.isArchived == false) | .name]') | ||
|
|
||
| CONSUMING=() | ||
| for repo in $(echo "$ALL_REPOS" | jq -r '.[]'); do | ||
| # Spring dette repo selv over | ||
| [ "$repo" = "bc-code-intelligence" ] && continue | ||
|
|
||
| # Tjek om repoet har en .gitmodules-fil der refererer til os | ||
| MODULES=$(gh api repos/kollabdk/$repo/contents/.gitmodules \ | ||
| --jq '.content' 2>/dev/null | base64 -d 2>/dev/null || true) | ||
|
|
||
| if echo "$MODULES" | grep -q "bc-code-intelligence"; then | ||
| CONSUMING+=("\"$repo\"") | ||
| fi | ||
| done | ||
|
|
||
| echo "repos=[$(IFS=,; echo "${CONSUMING[*]}")]" >> $GITHUB_OUTPUT | ||
|
|
Comment on lines
+35
to
+38
| MODULES=$(gh api repos/kollabdk/$repo/contents/.gitmodules \ | ||
| --jq '.content' 2>/dev/null | base64 -d 2>/dev/null || true) | ||
|
|
||
| if echo "$MODULES" | grep -q "bc-code-intelligence"; then |
mortenseifert
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hvad er ændret og hvorfor
bc-code-intelligenceindeholder vores AI-personas og domæneviden til Business Central. Disse filer bruges i alle vores repos via en git submodule — men submoduler opdaterer sig ikke automatisk. Tidligere ville alle andre repos pege på en gammel version, medmindre nogen manuelt gik ind og opdaterede dem i hvert enkelt repo.Hvad workflowet gør
Hver gang der pushes til
mainibc-code-intelligence, kører workflowet automatisk to trin:Trin 1 – Opdagelse
Workflowet spørger dynamisk GitHub API'et om alle aktive repos i
kollabdk-organisationen og finder dem, der harbc-code-intelligencesom submodule. Der er ingen hardkodet liste — nye repos inkluderes automatisk, blot ved at de tilføjer submodulen én gang.Trin 2 – Synkronisering
For hvert fundet repo opdateres submodule-pointeren til den nyeste commit. Opdateringen kører parallelt for op til 10 repos ad gangen. Hvis et repo allerede er opdateret, springes det over.
Valg: direkte commit vs. pull request
Workflowet er sat op til at committe direkte til
maini de forbrugende repos. Alternativet — at oprette en pull request pr. repo — er bevaret som kommentarer i YAML-filen, så det nemt kan skiftes til.Hvad der kræves for at det virker
Der skal oprettes én GitHub-hemmelighed i
bc-code-intelligence-repoet:ORG_SYNC_TOKEN— et personal access token (eller GitHub App-token) med skriveadgang til alle repos i organisationen.🤖 Generated with Claude Code