Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,47 @@ jobs:
uses: actions/checkout@v7
with:
token: ${{ secrets.BOT_PR_TOKEN }}
ref: ${{ github.event.repository.default_branch }}
path: scripts
sparse-checkout: |
.gitmodules
.github/workflows/common.sh
sparse-checkout-cone-mode: false
- name: Update Gentoo submodule
id: update-gentoo
working-directory: scripts
env:
WORK_SCRIPTS_DIR: "${{ github.workspace }}/scripts"
run: |
set -euo pipefail
source scripts/.github/workflows/common.sh
source .github/workflows/common.sh
prepare_git_repo
submodule=sdk_container/src/third_party/gentoo
url=$(git -C "${WORK_SCRIPTS_DIR}" config --file .gitmodules --get "submodule.${submodule}.url")
branch=$(git -C "${WORK_SCRIPTS_DIR}" config --file .gitmodules --get "submodule.${submodule}.branch")
url=$(git config --file .gitmodules --get "submodule.${submodule}.url")
branch=$(git config --file .gitmodules --get "submodule.${submodule}.branch")
read -r latest_commit _ < <(git ls-remote --exit-code "${url}" "refs/heads/${branch}")
short_commit=${latest_commit:0:12}
git -C "${WORK_SCRIPTS_DIR}" update-index --cacheinfo "160000,${latest_commit},${submodule}"
if git -C "${WORK_SCRIPTS_DIR}" diff --cached --quiet -- "${submodule}"; then
git update-index --cacheinfo "160000,${latest_commit},${submodule}"
if git diff --cached --quiet -- "${submodule}"; then
echo 'UPDATE_NEEDED=0' >>"${GITHUB_OUTPUT}"
exit 0
fi
git -C "${WORK_SCRIPTS_DIR}" commit --signoff -m "gentoo: Update to ${short_commit}"
git commit --signoff -m "gentoo: Update to ${short_commit}"
previous_branch="buildbot/update-gentoo-submodule"
default_branch="${{ github.event.repository.default_branch }}"
if git fetch --no-tags --no-recurse-submodules --depth=1000 origin \
"+refs/heads/${previous_branch}:refs/remotes/origin/${previous_branch}"; then
git fetch --no-tags --no-recurse-submodules --deepen=1000 origin "${default_branch}"
additional_commits=$(git rev-list --reverse --no-merges \
"origin/${default_branch}..origin/${previous_branch}" -- ":^:${submodule}")
if [[ -n "${additional_commits}" ]]; then
mapfile -t commits <<< "${additional_commits}"
if ! git cherry-pick "${commits[@]}"; then
echo '::warning::Could not replay additional commits; keeping only the Gentoo submodule update.'
git cherry-pick --abort
fi
fi
fi
cleanup_repo
echo 'UPDATE_NEEDED=1' >>"${GITHUB_OUTPUT}"
echo "LATEST_COMMIT=${latest_commit}" >>"${GITHUB_OUTPUT}"
Expand Down
Loading