proto-updated #40
This file contains hidden or 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
| name: Sync Multigres Proto | |
| on: | |
| repository_dispatch: | |
| types: [proto-updated] | |
| permissions: {} | |
| concurrency: | |
| group: sync-proto | |
| cancel-in-progress: false | |
| jobs: | |
| update-dependency: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App token for creating a PR | |
| id: app-token | |
| uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | |
| with: | |
| app-id: ${{ vars.MULTIGRES_BOT_APP_ID }} | |
| private-key: ${{ secrets.MULTIGRES_BOT_APP_PRIVATE_KEY }} | |
| owner: multigres | |
| repositories: multigres,multigres-operator | |
| - name: Validate SHA is on main | |
| env: | |
| SHA: ${{ github.event.client_payload.sha }} | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| [[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || { echo "bad SHA"; exit 1; } | |
| # confirm SHA is ancestor of multigres/main | |
| gh api "repos/multigres/multigres/compare/main...$SHA" --jq '.status' \ | |
| | grep -qE '^(identical|behind)$' || { echo "SHA not on main"; exit 1; } | |
| - name: Check out code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| persist-credentials: false | |
| - name: Set up Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version-file: go.mod | |
| - name: Set short SHA | |
| id: vars | |
| env: | |
| SHA: ${{ github.event.client_payload.sha }} | |
| run: echo "short_sha=${SHA:0:7}" >> "$GITHUB_OUTPUT" | |
| - name: Authenticate to GHCR | |
| env: | |
| TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: echo "$TOKEN" | docker login ghcr.io -u x-access-token --password-stdin | |
| - name: Verify upstream runtime images exist | |
| env: | |
| SHORT: ${{ steps.vars.outputs.short_sha }} | |
| run: | | |
| for image in multigres pgctld; do | |
| ref="ghcr.io/multigres/${image}:sha-${SHORT}" | |
| echo "Checking $ref" | |
| if ! docker manifest inspect "$ref" > /dev/null 2>&1; then | |
| echo "::error::Image $ref does not exist in GHCR — aborting sync. The upstream image build may not have completed yet; re-dispatch once it has." | |
| exit 1 | |
| fi | |
| done | |
| - name: Update multigres dependency | |
| env: | |
| GOPRIVATE: "github.com/multigres/*" | |
| SHA: ${{ github.event.client_payload.sha }} | |
| TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" | |
| go get github.com/multigres/multigres@"$SHA" | |
| go mod tidy | |
| - name: Bump default runtime images | |
| env: | |
| SHORT: ${{ steps.vars.outputs.short_sha }} | |
| run: | | |
| sed -i -E "s#ghcr\.io/multigres/pgctld:sha-[a-f0-9]+#ghcr.io/multigres/pgctld:sha-${SHORT}#g" api/v1alpha1/image_defaults.go | |
| sed -i -E "s#ghcr\.io/multigres/multigres:sha-[a-f0-9]+#ghcr.io/multigres/multigres:sha-${SHORT}#g" api/v1alpha1/image_defaults.go | |
| - name: Create pull request | |
| uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| commit-message: "chore(deps): bump multigres to ${{ steps.vars.outputs.short_sha }}" | |
| title: "chore(deps): sync multigres proto to ${{ steps.vars.outputs.short_sha }}" | |
| body: | | |
| Automated sync triggered by changes in multigres/multigres@${{ github.event.client_payload.sha }}. | |
| - `go.mod` bumped to `${{ steps.vars.outputs.short_sha }}` | |
| - Default runtime image tags in `api/v1alpha1/image_defaults.go` bumped to `sha-${{ steps.vars.outputs.short_sha }}` (verified to exist in GHCR before commit) | |
| branch: chore/sync-proto-${{ steps.vars.outputs.short_sha }} | |
| base: main | |
| delete-branch: true |