Skip to content

Add workflow to synchronize go mod changes with submodules #7

Add workflow to synchronize go mod changes with submodules

Add workflow to synchronize go mod changes with submodules #7

name: Synchronize go.mod in submodules
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
permissions:
contents: write
jobs:
synchronize-go-mod:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
id: octo-sts
with:
scope: sigstore/sigstore-go
identity: sync
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.octo-sts.outputs.token }}
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
- name: Synchronize go.mod in submodule
run: |
cd examples/oci-image-verification; go mod tidy
- name: Commit and push changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Changes detected:"
git diff
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git commit -a -s -m "Synchronize go.mod in submodules"
git push origin HEAD:${{ github.event.pull_request.head.ref }}
else
echo "No changes to commit"
fi