Files
RoutingTableToWg/.github/workflows/upstream-sync.yaml
T

76 lines
3.0 KiB
YAML

# The golangci-lint version lives in hack/golangci-lint.version, which Dependabot
# cannot parse. This bumps it and opens a PR.
#
# Events caused by GITHUB_TOKEN start no workflows. AUTOMATION_SSH_KEY is an optional
# repository secret holding the private half of a deploy key with write access; the
# branch is pushed over SSH with it, so pushes to an open PR run ci.yaml. Opening the PR
# is still a GITHUB_TOKEN event, so a new PR gets its checks from a dispatched run on
# its branch, as workflow_dispatch is the exception to that rule.
name: upstream-sync
on:
schedule:
- cron: "17 4 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
actions: write
jobs:
golangci-lint:
runs-on: ubuntu-latest
concurrency:
group: upstream-sync-golangci-lint
cancel-in-progress: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ssh-key: ${{ secrets.AUTOMATION_SSH_KEY }}
- id: detect
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
current=$(cat hack/golangci-lint.version)
latest=$(gh release view --repo golangci/golangci-lint --json tagName -q .tagName)
echo "current=${current}" >> "$GITHUB_OUTPUT"
echo "latest=${latest}" >> "$GITHUB_OUTPUT"
[ "${current}" = "${latest}" ] && echo "changed=false" >> "$GITHUB_OUTPUT" || echo "changed=true" >> "$GITHUB_OUTPUT"
- if: steps.detect.outputs.changed == 'true'
run: echo "${{ steps.detect.outputs.latest }}" > hack/golangci-lint.version
# A new release usually means new checks, so let the PR say whether we pass.
- if: steps.detect.outputs.changed == 'true'
id: lint
continue-on-error: true
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: ${{ steps.detect.outputs.latest }}
- if: steps.detect.outputs.changed == 'true'
id: pr
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
branch: automation/golangci-lint-version-sync
delete-branch: true
commit-message: "Bump golangci-lint to ${{ steps.detect.outputs.latest }}"
title: "Bump golangci-lint to ${{ steps.detect.outputs.latest }}"
body: |
Automated golangci-lint upstream sync.
- Previous: `${{ steps.detect.outputs.current }}`
- New: `${{ steps.detect.outputs.latest }}`
Result of running the new version against the tree: `${{ steps.lint.outcome }}`.
A failure here is expected when a release adds checks; the findings are in the
job log of the run that opened this PR.
- if: steps.pr.outputs.pull-request-operation == 'created'
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run ci.yaml --ref automation/golangci-lint-version-sync