-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: manifest synchronisation | ||
|
||
on: | ||
workflow_call: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.event.pull_request.number || github.sha }}-${{ inputs.additional_key }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
WORKTREE_PATH: /tmp/workspace | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Checkout manifest-schema branch | ||
run: ./tools/checkout-manifest-schema-branch.sh $WORKTREE_PATH | ||
|
||
- name: Copy over schema | ||
run: cp ./manifests/* $WORKTREE_PATH | ||
|
||
- name: Stage changes | ||
working-directory: ${{ env.WORKTREE_PATH }} | ||
run: git add . | ||
|
||
- name: Show diff | ||
working-directory: ${{ env.WORKTREE_PATH }} | ||
run: git diff | ||
|
||
- name: Detect changes | ||
id: changes | ||
working-directory: ${{ env.WORKTREE_PATH }} | ||
run: | | ||
# This output boolean tells us if the dependencies have actually changed | ||
echo "count=$(git status --porcelain=v1 | wc -l)" >> $GITHUB_OUTPUT | ||
- name: Commit and push | ||
# Only push if changes exist | ||
if: steps.changes.outputs.count > 0 | ||
working-directory: ${{ env.WORKTREE_PATH }} | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
git commit -m "Update manifest schema" | ||
git push origin HEAD |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -exuo pipefail | ||
|
||
cd "$(dirname "$0")" | ||
|
||
schema_version="$(grep 'version = "0.*.0"' ./manifest-schema/Cargo.toml | cut -d '.' -f 2)" | ||
branch="manifest-schema-${schema_version}" | ||
|
||
git worktree add --force "${1?}" | ||
cd "${1?}" | ||
|
||
if git fetch origin "$branch"; then | ||
git checkout "origin/${branch}" -B "${branch}" | ||
elif ! git checkout "$branch"; then | ||
# New branch with no history. Credit: https://stackoverflow.com/a/13969482 | ||
git checkout --orphan "${branch}" | ||
git rm --cached -r . || true | ||
fi |