-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/github_actions/actions/setup-node…
…-4.0.3
- Loading branch information
Showing
45 changed files
with
4,688 additions
and
891 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
name: Update Draft HIPs Data | ||
|
||
on: | ||
schedule: | ||
- cron: "0 */6 * * *" # Runs every 6 hours | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
update-draft-hips: | ||
if: github.ref == 'refs/heads/main' # Only run on main branch | ||
runs-on: improvement-proposals-linux-medium | ||
permissions: | ||
contents: write | ||
pull-requests: read | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
token: ${{ secrets.GH_ACCESS_TOKEN }} | ||
|
||
- name: Import GPG Key | ||
id: gpg_importer | ||
uses: step-security/ghaction-import-gpg@6c8fe4d0126a59d57c21f87c9ae5dd3451fa3cca # v6.1.0 | ||
with: | ||
git_commit_gpgsign: true | ||
git_tag_gpgsign: true | ||
git_user_signingkey: true | ||
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }} | ||
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }} | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Create Script | ||
run: | | ||
mkdir -p _data | ||
cat << 'EOF' > fetch-draft-hips.js | ||
const https = require('https'); | ||
async function makeGraphQLRequest(query, token) { | ||
return new Promise((resolve, reject) => { | ||
const options = { | ||
hostname: 'api.github.com', | ||
path: '/graphql', | ||
method: 'POST', | ||
headers: { | ||
'Authorization': `Bearer ${token}`, | ||
'Content-Type': 'application/json', | ||
'User-Agent': 'Node.js' | ||
} | ||
}; | ||
const req = https.request(options, (res) => { | ||
let data = ''; | ||
res.on('data', chunk => { data += chunk; }); | ||
res.on('end', () => resolve(JSON.parse(data))); | ||
}); | ||
req.on('error', reject); | ||
req.write(JSON.stringify({ query })); | ||
req.end(); | ||
}); | ||
} | ||
async function getAllPRs() { | ||
const query = ` | ||
query { | ||
repository(name: "hedera-improvement-proposal", owner: "hashgraph") { | ||
pullRequests(first: 100, states: [OPEN], orderBy: {field: CREATED_AT, direction: DESC}) { | ||
nodes { | ||
title | ||
number | ||
url | ||
headRefOid | ||
files(first: 100) { | ||
edges { | ||
node { | ||
path | ||
additions | ||
deletions | ||
} | ||
} | ||
} | ||
author { | ||
login | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
try { | ||
const result = await makeGraphQLRequest(query, process.env.GITHUB_TOKEN); | ||
if (result.errors) { | ||
console.error('GraphQL errors:', result.errors); | ||
process.exit(1); | ||
} | ||
return result.data.repository.pullRequests.nodes; | ||
} catch (error) { | ||
console.error('Error fetching PRs:', error); | ||
throw error; | ||
} | ||
} | ||
// Run the main function | ||
getAllPRs().then(prs => { | ||
const fs = require('fs'); | ||
fs.writeFileSync('_data/draft_hips.json', JSON.stringify(prs, null, 2)); | ||
}).catch(error => { | ||
console.error('Failed to fetch PRs:', error); | ||
process.exit(1); | ||
}); | ||
EOF | ||
- name: Run Script | ||
run: node fetch-draft-hips.js | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | ||
|
||
- name: Commit and Push Changes | ||
env: | ||
GITHUB_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} | ||
GITHUB_USER_NAME: ${{ secrets.GIT_USER_NAME }} | ||
run: | | ||
git config --local user.email "$GITHUB_USER_EMAIL" | ||
git config --local user.name "$GITHUB_USER_NAME" | ||
git add _data/draft_hips.json | ||
git commit -s -S -m "Update draft HIPs data [skip ci]" || echo "No changes to commit" | ||
git push origin main || echo "No changes to push" |
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
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
Oops, something went wrong.