Fetch latest versions #1648
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: Fetch latest versions | |
| on: | |
| schedule: | |
| # Run once a day at 10 AM EST | |
| - cron: "0 14 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| # Only allow a single fetch-versions workflow to run at a time so a manual run | |
| # and the scheduled run don't race on the fetch-versions PR branch. | |
| concurrency: ${{ github.workflow }} | |
| jobs: | |
| fetch-versions: | |
| if: github.repository == 'bufbuild/plugins' | |
| runs-on: ubuntu-latest-4-cores | |
| steps: | |
| - name: Generate token | |
| id: generate_token | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| with: | |
| client-id: ${{ secrets.TOKEN_EXCHANGE_GH_APP_CLIENT_ID }} | |
| private-key: ${{ secrets.TOKEN_EXCHANGE_GH_APP_PRIVATE_KEY }} | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - name: Checkout repository code | |
| uses: actions/checkout@v7 | |
| with: | |
| token: ${{ steps.generate_token.outputs.token }} | |
| fetch-depth: 0 # full history needed for update_frequency git log lookups | |
| - name: Install Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| check-latest: true | |
| - name: Get buf version | |
| shell: bash | |
| run: | | |
| echo BUF_VERSION=$(go list -m -f '{{.Version}}' github.com/bufbuild/buf | cut -c2-) >> $GITHUB_ENV | |
| - uses: bufbuild/buf-action@v1 | |
| with: | |
| setup_only: true | |
| - uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| - name: Fetch all versions | |
| id: fetch_versions | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| run: | | |
| go run ./internal/cmd/fetcher . | |
| - name: Archive plugin generated code | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: plugin-generated-code | |
| path: | | |
| tests/testdata/**/gen/** | |
| retention-days: 7 | |
| - name: Create PR | |
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| with: | |
| add-paths: . | |
| commit-message: "detected new plugin versions" | |
| branch: fetch-versions | |
| delete-branch: true | |
| title: ${{ steps.fetch_versions.outputs.pr_title }} | |
| body: ${{ steps.fetch_versions.outputs.pr_body }} | |
| assignees: mfridman, oliversun9, pkwarren | |
| token: ${{ steps.generate_token.outputs.token }} | |
| author: ${{ steps.generate_token.outputs.app-slug }}[bot] <${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com> | |
| committer: ${{ steps.generate_token.outputs.app-slug }}[bot] <${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com> | |
| - name: Generate Github Token | |
| id: generate_issues_token | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| if: ${{ failure() }} | |
| with: | |
| app-id: ${{ secrets.BUFBUILD_ISSUE_CREATOR_APP_ID }} | |
| private-key: ${{ secrets.BUFBUILD_ISSUE_CREATOR_APP_KEY }} | |
| permission-issues: write | |
| - uses: dblock/create-a-github-issue@a25e69ccb88998dc267170a0dbde8ef8ac3a491c # v3.4.0 | |
| if: ${{ failure() }} | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_issues_token.outputs.token }} | |
| GITHUB_SERVER_URL: ${{ github.server_url }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }} | |
| with: | |
| filename: .github/automatic-workflow-issue-template.md | |
| update_existing: true | |
| search_existing: open |