tools #15
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
| --- | |
| # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json | |
| name: tools | |
| "on": | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 8 * * 1" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| tools: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate token | |
| id: token | |
| uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2 | |
| with: | |
| app-id: ${{ secrets.TOKEN_EXCHANGE_APP }} | |
| private-key: ${{ secrets.TOKEN_EXCHANGE_KEY }} | |
| permission-contents: write | |
| permission-pull-requests: write | |
| permission-issues: write | |
| - name: Checkout source | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| with: | |
| token: ${{ steps.token.outputs.token }} | |
| fetch-depth: 0 | |
| - name: Setup golang | |
| uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Update golangci | |
| run: | | |
| TOOL="github.com/golangci/golangci-lint/v2/cmd/golangci-lint" | |
| MOD="$(go list -mod=readonly -f '{{.Module.Path}}' ${TOOL})" | |
| VERSION="$(go list -mod=readonly -u -json -m ${MOD} | jq -r .Update.Version)" | |
| if [[ "${VERSION}" != "null" ]]; then | |
| go get -tool "${TOOL}@${VERSION}" && go mod tidy | |
| fi | |
| - name: Update revive | |
| run: | | |
| TOOL="github.com/mgechev/revive" | |
| MOD="$(go list -mod=readonly -f '{{.Module.Path}}' ${TOOL})" | |
| VERSION="$(go list -mod=readonly -u -json -m ${MOD} | jq -r .Update.Version)" | |
| if [[ "${VERSION}" != "null" ]]; then | |
| go get -tool "${TOOL}@${VERSION}" && go mod tidy | |
| fi | |
| - name: Create request | |
| id: request | |
| uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8 | |
| with: | |
| branch: update/tools | |
| delete-branch: true | |
| committer: "GitHub Actions <github@webhippie.de>" | |
| commit-message: "ci: automated tool updates" | |
| signoff: true | |
| title: "ci: automated tool updates" | |
| body: "New versions updated, automerge should handle that!" | |
| labels: tools | |
| token: ${{ steps.token.outputs.token }} | |
| - name: Approve request | |
| if: steps.request.outputs.pull-request-operation == 'created' | |
| run: gh pr review --approve "${{ steps.request.outputs.pull-request-number }}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Enable automerge | |
| if: steps.request.outputs.pull-request-operation == 'created' | |
| run: gh pr merge --rebase --auto "${{ steps.request.outputs.pull-request-number }}" | |
| env: | |
| GH_TOKEN: ${{ steps.token.outputs.token }} | |
| ... |