|
| 1 | +name: Update Submodule Dependencies |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + # Only run if changes affect the root module (not submodules themselves) |
| 7 | + paths-ignore: |
| 8 | + - "cmd/openapi/**" |
| 9 | + - "openapi/linter/customrules/**" |
| 10 | + - ".github/workflows/update-submodule-dependencies.yaml" |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + update-dependencies: |
| 18 | + name: Update submodule dependencies |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v6 |
| 22 | + |
| 23 | + - name: Setup Go |
| 24 | + uses: actions/setup-go@v6 |
| 25 | + with: |
| 26 | + go-version-file: "go.mod" |
| 27 | + cache: false # Disable caching to ensure fresh dependency resolution |
| 28 | + |
| 29 | + - name: Update openapi/linter/customrules go.mod |
| 30 | + run: | |
| 31 | + cd openapi/linter/customrules |
| 32 | +
|
| 33 | + # Update to latest main commit |
| 34 | + go get github.com/speakeasy-api/openapi@main |
| 35 | + go mod tidy |
| 36 | +
|
| 37 | + - name: Update cmd/openapi go.mod |
| 38 | + run: | |
| 39 | + cd cmd/openapi |
| 40 | +
|
| 41 | + # Update to latest main commit (both main module and customrules) |
| 42 | + go get github.com/speakeasy-api/openapi@main |
| 43 | + go get github.com/speakeasy-api/openapi/openapi/linter/customrules@main |
| 44 | + go mod tidy |
| 45 | +
|
| 46 | + - name: Check for changes |
| 47 | + id: changes |
| 48 | + run: | |
| 49 | + CHANGED_FILES="" |
| 50 | +
|
| 51 | + # Check customrules module |
| 52 | + if ! git diff --quiet openapi/linter/customrules/go.mod openapi/linter/customrules/go.sum 2>/dev/null; then |
| 53 | + CHANGED_FILES="${CHANGED_FILES}customrules " |
| 54 | + fi |
| 55 | +
|
| 56 | + # Check cmd/openapi module |
| 57 | + if ! git diff --quiet cmd/openapi/go.mod cmd/openapi/go.sum 2>/dev/null; then |
| 58 | + CHANGED_FILES="${CHANGED_FILES}cmd " |
| 59 | + fi |
| 60 | +
|
| 61 | + if [ -z "$CHANGED_FILES" ]; then |
| 62 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 63 | + echo "No changes detected" |
| 64 | + else |
| 65 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 66 | + echo "modules=${CHANGED_FILES}" >> $GITHUB_OUTPUT |
| 67 | + echo "Changes detected in: ${CHANGED_FILES}" |
| 68 | +
|
| 69 | + # Get the new version for the PR description |
| 70 | + NEW_VERSION=$(grep 'github.com/speakeasy-api/openapi v' cmd/openapi/go.mod | head -1 | awk '{print $2}') |
| 71 | + echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT |
| 72 | + echo "Updated to version: ${NEW_VERSION}" |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Create Pull Request |
| 76 | + if: steps.changes.outputs.changed == 'true' |
| 77 | + uses: peter-evans/create-pull-request@v8 |
| 78 | + with: |
| 79 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + commit-message: | |
| 81 | + chore: update submodule dependencies to latest main |
| 82 | +
|
| 83 | + Updates go.mod files in submodules to use the latest commit from main. |
| 84 | + Version: ${{ steps.changes.outputs.version }} |
| 85 | + Updated modules: ${{ steps.changes.outputs.modules }} |
| 86 | + branch: bot/update-submodule-dependencies |
| 87 | + delete-branch: true |
| 88 | + title: "chore: update submodule dependencies to latest main" |
| 89 | + body: | |
| 90 | + ## Updates submodule dependencies |
| 91 | +
|
| 92 | + This PR updates the `go.mod` files in submodules to reference the latest commit from main. |
| 93 | +
|
| 94 | + **Updated to:** `${{ steps.changes.outputs.version }}` |
| 95 | + **Updated modules:** ${{ steps.changes.outputs.modules }} |
| 96 | +
|
| 97 | + **Changes:** |
| 98 | + - Updated `github.com/speakeasy-api/openapi` dependency in submodule go.mod files |
| 99 | + - Ran `go mod tidy` to update dependencies |
| 100 | +
|
| 101 | + --- |
| 102 | + *This PR was automatically created by the [update-submodule-dependencies workflow](.github/workflows/update-submodule-dependencies.yaml)* |
| 103 | + labels: | |
| 104 | + dependencies |
| 105 | + automated |
| 106 | +
|
| 107 | + - name: Summary |
| 108 | + run: | |
| 109 | + if [ "${{ steps.changes.outputs.changed }}" == "true" ]; then |
| 110 | + echo "✅ Pull request created to update submodule dependencies" |
| 111 | + echo "Version: ${{ steps.changes.outputs.version }}" |
| 112 | + echo "Modules: ${{ steps.changes.outputs.modules }}" |
| 113 | + else |
| 114 | + echo "ℹ️ No changes needed - submodule dependencies already up to date" |
| 115 | + fi |
0 commit comments