Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2a21fb0
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
5329c32
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
2028fc3
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
3dc8541
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
1023c60
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
47adb82
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
41f0ecf
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
367b787
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
baffafb
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
ac577ec
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
31d551a
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
e7a2644
Changelog entry about linguist added
jakubdomanski May 13, 2026
16dd33f
re-generated known_files_gen.go
jakubdomanski May 13, 2026
de786a9
chore: update GitHub Actions workflow to generate known_files_gen.go …
jakubdomanski May 13, 2026
7d8e5e3
Merge pull request #1 from jakubdomanski/feat/466-linguist
jakubdomanski May 13, 2026
54dbdb1
chore: add GitHub Actions workflow to update linguist SHA and modify …
jakubdomanski May 13, 2026
043e54e
test: main + known_files
jakubdomanski May 13, 2026
b09ca96
known_files_gen step fix
jakubdomanski May 13, 2026
33e7a7c
chore: update command to generate known_files_gen.go using 'go generate'
jakubdomanski May 13, 2026
c947c4e
chore: format YAML for generating known_files_gen.go step
jakubdomanski May 13, 2026
727473e
chore: update usage instructions for local command execution in known…
jakubdomanski May 13, 2026
12cfd15
chore: update go:generate command for knownfiles generation
jakubdomanski May 13, 2026
673f338
chore: update generate command in workflow and improve comments in ma…
jakubdomanski May 13, 2026
c54887d
chore: remove build constraint from knownfiles generator command
jakubdomanski May 13, 2026
886640f
chore: Updated coverage badge.
actions-user May 13, 2026
ad8281e
chore: update go:generate command to run from current directory
jakubdomanski May 13, 2026
0d67ac5
chore: update go:generate command to run from the correct relative path
jakubdomanski May 13, 2026
082850a
reverert main.go comment
jakubdomanski May 13, 2026
c68a38b
chore: update go:generate command to reference the correct file path
jakubdomanski May 13, 2026
0063ec3
chore: Updated coverage badge.
actions-user May 13, 2026
2fc8140
chore: update PR body to include regeneration of known_files_gen.go w…
jakubdomanski May 13, 2026
d9101e0
chore: update github-linguist SHA
actions-user May 13, 2026
105d7af
Merge pull request #11 from jakubdomanski/autopr/25805998168-1
jakubdomanski May 13, 2026
04bcca8
Revert "chore: update github-linguist SHA to e535c9adf5306132e9df0b75…
jakubdomanski May 13, 2026
08c330a
Merge pull request #12 from jakubdomanski/revert-11-autopr/25805998168-1
jakubdomanski May 13, 2026
68024e0
chore: update github-linguist SHA
actions-user May 13, 2026
fb3d310
Merge pull request #13 from jakubdomanski/autopr/25806227410-1
jakubdomanski May 13, 2026
a415b81
Revert "chore: update github-linguist SHA to e535c9adf5306132e9df0b75…
jakubdomanski May 13, 2026
8012c4d
Merge pull request #14 from jakubdomanski/revert-13-autopr/25806227410-1
jakubdomanski May 13, 2026
0e0c166
chore: update github-linguist SHA
actions-user May 13, 2026
1ffdca4
Merge pull request #15 from jakubdomanski/autopr/25806365040-2
jakubdomanski May 13, 2026
df2cd1c
chore: rename workflow to 'Linguist update' for clarity
jakubdomanski May 13, 2026
ffaa792
Revert "chore: update github-linguist SHA to e535c9adf5306132e9df0b75…
jakubdomanski May 13, 2026
bc33381
Merge pull request #16 from jakubdomanski/revert-15-autopr/25806365040-2
jakubdomanski May 13, 2026
c3b564f
chore: enhance PR check to prevent duplicates for Linguist SHA updates
jakubdomanski May 13, 2026
88ee653
chore: update github-linguist SHA
actions-user May 13, 2026
41d71e5
chore: refine PR check to use consistent search format for existing S…
jakubdomanski May 13, 2026
153fb52
chore: remove unnecessary condition for PR check in Linguist workflow
jakubdomanski May 13, 2026
7df921a
chore: fix search format for existing PR check in Linguist workflow
jakubdomanski May 13, 2026
ac5efe2
chore: fix formatting in existing PR check for Linguist SHA updates
jakubdomanski May 13, 2026
d03598e
chore: enhance PR check to skip creation if existing SHA found
jakubdomanski May 13, 2026
41bf028
chore: improve SHA validation and ensure consistent output in PR check
jakubdomanski May 13, 2026
33bacda
Merge pull request #17 from jakubdomanski/autopr/25808773491-1
jakubdomanski May 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/linguist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# GitHub Actions Workflow: Linguist
# This workflow file defines automation tasks for the Linguist tool
---
name: Linguist update

on:
schedule:
- cron: '0 0 * * 1' # every monday at midnight
workflow_dispatch: # yamllint disable-line rule:truthy - false positive

permissions:
contents: read
pull-requests: read

jobs:
update-sha:
name: Update Linguist SHA
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Fetch latest Linguist SHA
id: fetch-sha
run: |
SHA=$(git ls-remote https://github.com/github/linguist.git HEAD | awk '{print $1}')
[[ -z "$SHA" ]] && { echo "Empty output"; exit 1; }
[[ ! "$SHA" =~ ^[0-9a-f]{40}$ ]] && { echo "Invalid SHA format"; exit 1; }

echo "sha=$SHA" >> "$GITHUB_OUTPUT"

- name: Check existing PR
id: check-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SHA_EXISTS=$(gh pr list \
--state open \
--search "in:title \"chore: update github-linguist SHA to ${{ steps.fetch-sha.outputs.sha }}\"" \
--json number \
--jq 'length' \
--repo "${{ github.repository }}")

if [[ "$SHA_EXISTS" != "0" ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Skipping PR creation - existing PR with same SHA found"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Update pinned SHA in internal/generate/knownfiles/main.go
id: update-sha
if: steps.check-pr.outputs.skip != 'true'
run: |
FILEPATH=internal/generate/knownfiles/main.go
SHA_REGEX='[0-9a-f]{40}'
FIELD_REGEX='linguistSHA\s*=\s*"'

if ! grep -qE 'linguistSHA\s*=\s*"[0-9a-f]{40}"' "$FILEPATH"; then
echo "Missing linguistSHA line"
exit 1
fi

EXISTING_SHA=$(grep -oE "${FIELD_REGEX}${SHA_REGEX}" "$FILEPATH" | grep -oE "$SHA_REGEX")

if [[ "$EXISTING_SHA" == "${{ steps.fetch-sha.outputs.sha }}" ]]; then
echo "SHA already up to date, skipping"
exit 0
fi

sed -E -i "s/(${FIELD_REGEX})${SHA_REGEX}(\")/\1${{ steps.fetch-sha.outputs.sha }}\2/" "$FILEPATH"

if git diff --quiet; then
echo "sha_updated=false" >> "$GITHUB_OUTPUT"
else
echo "sha_updated=true" >> "$GITHUB_OUTPUT"
fi

- name: Generate known_files_gen.go
if: steps.update-sha.outputs.sha_updated == 'true' && steps.check-pr.outputs.skip != 'true'
run: |
go generate ./pkg/filetype/file_type.go
git diff pkg/filetype/known_files_gen.go

- name: Commit changes
if: steps.update-sha.outputs.sha_updated == 'true' && steps.check-pr.outputs.skip != 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add internal/generate/knownfiles/main.go pkg/filetype/known_files_gen.go
git commit -m "chore: update github-linguist SHA"

- name: Create branch and push
id: create-branch
if: steps.update-sha.outputs.sha_updated == 'true' && steps.check-pr.outputs.skip != 'true'
run: |
BRANCH="autopr/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
git checkout -b "$BRANCH"
git push --set-upstream origin "$BRANCH"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"

- name: Create pull request
if: steps.update-sha.outputs.sha_updated == 'true' && steps.check-pr.outputs.skip != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "chore: update github-linguist SHA to ${{ steps.fetch-sha.outputs.sha }}" \
--body "## Automated SHA bump

Bumps the pinned [github/linguist](https://github.com/github/linguist) SHA in the file [internal/generate/knownfiles/main.go](internal/generate/knownfiles/main.go) to the latest version.
Also regenerates the [pkg/filetype/known_files_gen.go](pkg/filetype/known_files_gen.go) file with the updated SHA and includes it in the PR.

> This PR was automatically created by workflow run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
--base ${{ github.event.repository.default_branch }} \
--head ${{ steps.create-branch.outputs.branch }}

- name: Cleanup branch on failure
if: failure() && steps.create-branch.outputs.branch != ''
run: |
git push origin --delete "${{ steps.create-branch.outputs.branch }}" || true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- JSON and JSONC treated as a family for `--file-types` and `--exclude-file-types`
- `go generate` step in CI pipeline to keep Linguist data fresh
- CI lint check to ensure generated files are committed up to date
- Automated Linguist SHA updates via scheduled GitHub Actions workflow (`linguist.yml`) that checks SHA weekly

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion internal/generate/knownfiles/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
)

const (
linguistURL = "https://raw.githubusercontent.com/github-linguist/linguist/refs/heads/main/lib/linguist/languages.yml"
linguistSHA = "e535c9adf5306132e9df0b75ffe1ce2679873fe8" // DevSkim: ignore DS173237 - this is a commit SHA, not a secret
linguistURL = "https://raw.githubusercontent.com/github-linguist/linguist/" + linguistSHA + "/lib/linguist/languages.yml"
outputFile = "known_files_gen.go"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/filetype/known_files_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.