Export EDBP Plugin Data (Final) #1991
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: Export EDBP Plugin Data (Final) | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 * * * *' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Fetch and Process Data | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TOPIC_NAME: "edbp-plugin" | |
| run: | | |
| echo "--- Searching for repositories with topic: $TOPIC_NAME ---" | |
| # 1. 検索時は 'fullName' を使用 | |
| REPOS=$(gh search repos --topic "$TOPIC_NAME" --json fullName -q '.[].fullName') | |
| if [ -z "$REPOS" ]; then | |
| echo "::error::No repositories found with topic: $TOPIC_NAME" | |
| exit 1 | |
| fi | |
| echo "[]" > edbp_data.json | |
| for REPO in $REPOS; do | |
| echo "Processing: $REPO" | |
| OWNER=${REPO%/*} | |
| NAME=${REPO#*/} | |
| # 2. GraphQLクエリ | |
| QUERY=' | |
| query($owner:String!, $name:String!) { | |
| repository(owner:$owner, name:$name) { | |
| nameWithOwner | |
| url | |
| stargazerCount | |
| forkCount | |
| manifestFile: object(expression: "HEAD:manifest.json") { | |
| ... on Blob { | |
| text | |
| } | |
| } | |
| refs(refPrefix: "refs/heads/", first: 10) { | |
| nodes { | |
| branchName: name | |
| target { | |
| ... on Commit { | |
| history(first: 30) { | |
| nodes { | |
| shortId: abbreviatedOid | |
| longId: oid | |
| message | |
| committedDate | |
| author { | |
| name | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| releases(first: 10, orderBy: {field: CREATED_AT, direction: DESC}) { | |
| nodes { | |
| tagName | |
| name | |
| publishedAt | |
| } | |
| } | |
| } | |
| }' | |
| # API実行 | |
| gh api graphql -f query="$QUERY" -f owner="$OWNER" -f name="$NAME" \ | |
| --jq '.data.repository' > single_repo.json | |
| # 3. JSONの整形 | |
| if [ -s single_repo.json ] && [ "$(cat single_repo.json)" != "null" ]; then | |
| jq ' | |
| if .manifestFile and .manifestFile.text then | |
| .manifest = (.manifestFile.text | fromjson) | |
| else | |
| .manifest = null | |
| end | | |
| del(.manifestFile) | | |
| .branches = [.refs.nodes[] | { | |
| name: .branchName, | |
| commits: (if .target.history then [.target.history.nodes[] | { | |
| shortId: .shortId, | |
| longId: .longId, | |
| message: .message, | |
| date: .committedDate, | |
| author: .author.name | |
| }] else [] end) | |
| }] | | |
| del(.refs) | |
| ' single_repo.json > processed_repo.json | |
| jq ". += [$(cat processed_repo.json)]" edbp_data.json > temp.json && mv temp.json edbp_data.json | |
| fi | |
| done | |
| - name: Commit and Push | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add edbp_data.json | |
| if ! git diff --cached --exit-code; then | |
| git commit -m "Update edbp-plugin data: Fix history query and IDs" | |
| git push | |
| fi |