From 92b08ff006cde10e55da9fb7f2c318f4ff6f14b4 Mon Sep 17 00:00:00 2001 From: Alok Gupta Date: Mon, 24 Jun 2024 23:55:50 +0530 Subject: [PATCH 1/2] github-actions : added sync.contributors.yml --- .github/workflows/sync-contributors.yml | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/sync-contributors.yml diff --git a/.github/workflows/sync-contributors.yml b/.github/workflows/sync-contributors.yml new file mode 100644 index 000000000..7325c2910 --- /dev/null +++ b/.github/workflows/sync-contributors.yml @@ -0,0 +1,59 @@ +name : Sync Contributors Data + +on: + schedule: # Run sunday at midnight every week + - cron: '0 0 * * 0' + workflow_dispatch: + +jobs: + sync-contributors-data: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Get Token + uses: actions/create-github-app-token@v1 + id: get_workflow_token + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + + - name: Fetch Contributors data + uses: actions/github-script@v7 + env: + ORGS: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + with: + github-token: ${{ steps.get_workflow_token.outputs.token }} + script: | + const fs = require('fs'); + + let data = await github.paginate(github.rest.repos.listContributors, { + owner: process.env.ORGS, + repo: process.env.REPO, + per_page: 100, + headers: { + "X-GitHub-Api-Version": "2022-11-28", + }, + }); + + // Filter the data to get only the required fields + data = data.map(({ login, id, avatar_url, html_url }) => + ({ login, id, avatar_url, html_url })); + + // Store the data in a file + fs.writeFileSync('community.json', JSON.stringify(data, null, 2)); + + - name: Commit changes + env: + GITHUB_APP_TOKEN: ${{ steps.get_workflow_token.outputs.token }} + run: | + git config user.name "the-json-schema-bot[bot]" + git config user.email "the-json-schema-bot[bot]@users.noreply.github.com" + git add community.json + git diff --quiet && git diff --staged --quiet || (git commit -m "chore(community): update community.json" && git push "https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#refs/heads/}) + + + + From 440b18f06cef0f06420c5fa9182f468bb833c7be Mon Sep 17 00:00:00 2001 From: Alok Gupta Date: Mon, 24 Jun 2024 23:58:35 +0530 Subject: [PATCH 2/2] github-actions : Added sync-project-roadmap.yml --- .github/workflows/sync-project-roadmap.yml | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/sync-project-roadmap.yml diff --git a/.github/workflows/sync-project-roadmap.yml b/.github/workflows/sync-project-roadmap.yml new file mode 100644 index 000000000..238af4819 --- /dev/null +++ b/.github/workflows/sync-project-roadmap.yml @@ -0,0 +1,100 @@ +name : Sync Project Roadmap Data + +on: + schedule: # Run sundat at 00:05 every week + - cron: '5 0 * * 0' + workflow_dispatch: + +jobs: + sync-roadmap-data: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get Token + uses: actions/create-github-app-token@v1 + id: get_workflow_token + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + + # fetch project data and store it in a file + - name: Fetch project data + env: + GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }} # GitHub App token stored in secrets + PROJECT_ID: ${{vars.ROADMAP_PROJECT_ID}} # Project ID + run: | + gh api graphql -f query=' + query($PROJECT_ID : ID!) { + node(id: $PROJECT_ID) { + ... on ProjectV2 { + items(first: 20) { + nodes { + id + fieldValues(first: 8) { + nodes { + ... on ProjectV2ItemFieldTextValue { + text + field { + ... on ProjectV2FieldCommon { + name + } + } + } + ... on ProjectV2ItemFieldDateValue { + date + field { + ... on ProjectV2FieldCommon { + name + } + } + } + ... on ProjectV2ItemFieldSingleSelectValue { + name + field { + ... on ProjectV2FieldCommon { + name + } + } + } + } + } + content { + ... on DraftIssue { + title + body + } + ... on Issue { + title + assignees(first: 10) { + nodes { + login + } + } + } + ... on PullRequest { + title + assignees(first: 10) { + nodes { + login + } + } + } + } + } + } + } + } + }' -f PROJECT_ID=$PROJECT_ID | jq '.data.node.items.nodes' > project_data.json + + # commit updated project data + - name: Commit changes + env: + GITHUB_APP_TOKEN: ${{ steps.get_workflow_token.outputs.token }} + run: | + git config user.name "the-json-schema-bot[bot]" + git config user.email "the-json-schema-bot[bot]@users.noreply.github.com" + git add project_data.json + git diff --quiet && git diff --staged --quiet || (git commit -m "chore(project_data): update project_data.json" && git push "https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#refs/heads/}) +