Generate Library Metadata #95
This file contains 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: Generate Library Metadata | |
on: | |
schedule: | |
- cron: 0 0 * * 0 | |
workflow_dispatch: | |
jobs: | |
build-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: generate matrix | |
id: matrix | |
run: | | |
echo "matrix=$(ls implementations | jq -cnR '[inputs | select(. | test("^[a-z]") and . != "appsync" and . != "stepzen" and . != "dgraph")]')" >> $GITHUB_OUTPUT | |
metadata: | |
needs: build-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
name: ${{ fromJson(needs.build-matrix.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Read Subgraph GH Details | |
id: subgraph_details | |
run: | | |
echo "REPOSITORY_NAME=$(jq -r '.repository.name' implementations/${{ matrix.name }}/metadata.json)" >> $GITHUB_OUTPUT | |
echo "REPOSITORY_OWNER=$(jq -r '.repository.owner' implementations/${{ matrix.name }}/metadata.json)" >> $GITHUB_OUTPUT | |
- uses: octokit/[email protected] | |
id: repository_metadata | |
with: | |
query: | | |
query repositoryMetadata($owner:String!,$repo:String!) { | |
repository(owner:$owner,name:$repo) { | |
description | |
stargazerCount | |
releases(first:1) { | |
nodes { | |
publishedAt | |
} | |
} | |
} | |
} | |
owner: ${{ steps.subgraph_details.outputs.REPOSITORY_OWNER }} | |
repo: ${{ steps.subgraph_details.outputs.REPOSITORY_NAME }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: "echo 'latest release: ${{ steps.repository_metadata.outputs.data }}'" | |
- run: | | |
echo '${{ steps.repository_metadata.outputs.data }}' | jq '.["description"] = .repository.description | .["stargazerCount"] = .repository.stargazerCount | .["lastRelease"] = .repository.releases.nodes[0].publishedAt | del(.repository)' > github_metadata.json | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.name }} | |
path: github_metadata.json | |
retention-days: 1 | |
update_metadata: | |
needs: metadata | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Metadata | |
uses: actions/download-artifact@v4 | |
with: | |
path: implementations | |
- name: Check if there are any updates | |
id: git_updates | |
run: | | |
if [ -n "$(git status --porcelain)" ]; | |
then | |
echo "GIT_UPDATES=false" >> $GITHUB_OUTPUT | |
else | |
echo "GIT_UPDATES=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit changes | |
if: ${{ steps.git_updates.outputs.GIT_UPDATES }} | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "github-action" | |
git checkout -b metadata_updates | |
git add . | |
git commit -m 'docs: subgraph library metadata updates' | |
git push origin metadata_updates | |
- name: Create PR | |
run: | | |
gh pr create -B main -H metadata_updates --title 'docs: subgraph library metadata updates' --body 'Created by Github Action' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |