Skip to content

Commit

Permalink
Makes workflows/syncsubdeps idempotent.
Browse files Browse the repository at this point in the history
Uses the commit hash from the deps/*_*/ directories, instead of HEAD.
  • Loading branch information
tommie committed Dec 30, 2023
1 parent 2cfd4dd commit 3bad195
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/syncsubdeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,33 @@ jobs:
set -o pipefail
go work init . $(ls ./deps/*_*/cgo.go | xargs -r dirname)
- name: Update go.mod
- id: info
name: Extract Information
run: |
set -o pipefail
submods=(
$(find deps -maxdepth 2 -type f -name libmanifest | \
xargs -r dirname | \
xargs -rn1 basename | \
while read os_arch; do
echo "github.com/${{ github.repository }}/deps/$os_arch@${{ github.sha }}"
echo "github.com/${{ github.repository }}/deps/$os_arch"
done)
)
go get "${submods[@]}"
- id: info
name: Extract Information
run: |
sha="${{ github.sha }}"
# This is the latest commit affecting any file in the submodules.
# Thus, this workflow is idempotent.
sha="$(git log -n 1 --pretty=format:%H "${submods[@]}")"
echo "submodules=${submods[*]}" >>"$GITHUB_OUTPUT"
echo "sha=$sha" >>"$GITHUB_OUTPUT"
echo "short-sha=${sha::8}" >>"$GITHUB_OUTPUT"
- name: Update go.mod
run: |
sha="${{ steps.info.outputs.sha }}"
submods=( $(for submod in ${{ steps.info.outputs.submodules }}; do echo "$submod@$sha" ; done) )
go get "${submods[@]}"
- id: create_pr
name: Create PR
uses: peter-evans/create-pull-request@v5
Expand Down

0 comments on commit 3bad195

Please sign in to comment.