Skip to content

Commit

Permalink
submodule-sync: make fewer path assumptions (#90)
Browse files Browse the repository at this point in the history
Before this commit,
`per-submodule-build-matrix.sh` assumed that the
top level of the repo it was syncing was at
`../../../../../`, which happened to be true for
all of our repos. As of
reboot-dev/mono@323ce51
however, that is no longer true.

This commit makes the script look up the top-level
of its containing repo dynamically, with its only
assumption being that the script is being run from
a submodule itself - which still holds.

TESTED: checked that the `submodule-sync` workflow
passes again for the `reboot-dev/respect` repo
where it was previously broken.
  • Loading branch information
rjhuijsman authored Oct 25, 2024
1 parent c050799 commit 45088e2
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/scripts/per-submodule-build-matrix.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
#!/bin/bash

# We'll print some debug information along the way.
echo "Started in working directory '$(pwd)'..."

# Assumption: this script is being run from _inside_ a submodule, but is
# supposed to act on the repo that _contains_ that submodule. Change our working
# directory accordingly.
cd "$(git rev-parse --show-toplevel)/.."

gitmodules_path="$(git rev-parse --show-toplevel)/.gitmodules"
echo "Assumed relevant '.gitmodules' file is '$gitmodules_path'"

# Update references.
git submodule update --recursive --remote

# The following condition is needed to set required outputs.
# The step generates one output: `path_matrix`.
# `path_matrix` output contains list of all submodules within a repo.
# The flag is used by the main build job.
echo "path_matrix=[$(git config --file ../../../../../.gitmodules --get-regexp path | \
awk '{ print $2 }' | \
awk '{ printf "%s\"%s\"", (NR==1?"":", "), $0 } END{ print "" }')]" >> $GITHUB_OUTPUT
output=$( \
echo "path_matrix=[$(git config --file "$gitmodules_path" --get-regexp path | \
awk '{ print $2 }' | \
awk '{ printf "%s\"%s\"", (NR==1?"":", "), $0 } END{ print "" }')]" \
)
echo "####"
echo $output
echo "####"
echo $output >> $GITHUB_OUTPUT

0 comments on commit 45088e2

Please sign in to comment.