Skip to content

chore: refresh stars, prune dead repositories, regenerate README and … #284

chore: refresh stars, prune dead repositories, regenerate README and …

chore: refresh stars, prune dead repositories, regenerate README and … #284

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go vet ./...
- run: go test ./...
validate:
name: Validate entries
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Files are in canonical form
run: go run ./cmd/awesome fmt -check
- name: Entry rules (offline)
run: go run ./cmd/awesome validate
- name: One new entry per pull request
if: github.event_name == 'pull_request'
run: |
added=$(git diff --name-only --diff-filter=A "origin/${{ github.base_ref }}...HEAD" -- entries/ links/ | sed '/^$/d')
count=$(printf '%s' "$added" | grep -c . || true)
if [ "$count" -gt 1 ]; then
echo "::error::A pull request may add only one entry so each can be reviewed on its own. This one adds $count:"
echo "$added"
exit 1
fi
- name: Generated files were not edited by hand
if: github.event_name == 'pull_request'
run: |
changed=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" -- README.md metadata.json badges/ docs/)
if [ -n "$changed" ]; then
echo "::error::These files are generated from list.json and entries/; do not edit them in a pull request:"
echo "$changed"
exit 1
fi
- name: Snapshot the base branch
if: github.event_name == 'pull_request'
run: |
mkdir -p "$RUNNER_TEMP/base"
paths="list.json entries"
if git cat-file -e "origin/${{ github.base_ref }}:links" 2>/dev/null; then paths="$paths links"; fi
git archive "origin/${{ github.base_ref }}" $paths | tar -x -C "$RUNNER_TEMP/base"
- name: Show the reviewer what the category already holds
if: github.event_name == 'pull_request'
continue-on-error: true # read-only token on fork PRs cannot comment; the job summary still has it
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
go run ./cmd/awesome compare -base "$RUNNER_TEMP/base" > "$RUNNER_TEMP/compare.md"
if [ ! -s "$RUNNER_TEMP/compare.md" ]; then
echo "No new entries in this pull request."
exit 0
fi
cat "$RUNNER_TEMP/compare.md" >> "$GITHUB_STEP_SUMMARY"
existing=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \
--jq '.[] | select(.body | startswith("<!-- awesome-compare -->")) | .id' | head -n 1)
if [ -n "$existing" ]; then
gh api -X PATCH "repos/$REPO/issues/comments/$existing" -F body=@"$RUNNER_TEMP/compare.md" > /dev/null
else
gh pr comment "$PR" --body-file "$RUNNER_TEMP/compare.md"
fi
- name: Repository checks on GitHub (new and changed entries only)
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: go run ./cmd/awesome validate -remote -base "$RUNNER_TEMP/base"