diff --git a/.gitignore b/.gitignore index 8b13789..6b7659d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,99 @@ +# Custom gitignores + +.DS_Store +logs/ + + +# Covers VSCode +**/node_modules +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/check-pr-blockage/action.yml b/check-pr-blockage/action.yml new file mode 100644 index 0000000..dfef15c --- /dev/null +++ b/check-pr-blockage/action.yml @@ -0,0 +1,9 @@ +name: 'Check PR for Blockage' +description: 'Fail if the first PR comment contains a blockage notice' +runs: + using: 'node20' + main: 'index.js' +inputs: + github-token: + description: 'GitHub token for accessing the PR comments' + required: true \ No newline at end of file diff --git a/check-pr-blockage/index.js b/check-pr-blockage/index.js new file mode 100644 index 0000000..cfcbba3 --- /dev/null +++ b/check-pr-blockage/index.js @@ -0,0 +1,57 @@ +const core = require('@actions/core'); +const github = require('@actions/github'); + +async function run() { + try { + const token = core.getInput('github-token', { required: true }); + const octokit = github.getOctokit(token); + + const { owner, repo, number: currentPRNumber } = github.context.issue; + + // Fetch all comments of the PR + const { data: comments } = await octokit.rest.issues.listComments({ + owner, + repo, + issue_number: currentPRNumber, + }); + + if (comments.length === 0) { + core.setFailed('No comments found in the PR.'); + return; + } + + const blockedByRegex = /blocked by #(\d+)/i; + let isBlocked = false; + + for (const comment of comments) { + const match = blockedByRegex.exec(comment.body); + if (match) { + const blockingPRNumber = match[1]; + + // Check if the blocking PR is merged + const { data: pr } = await octokit.rest.pulls.get({ + owner, + repo, + pull_number: blockingPRNumber, + }); + + if (!(pr.merged || pr.state === 'closed')) { + core.setFailed(`PR is blocked by an unmerged PR #${blockingPRNumber}.`); + isBlocked = true; + break; // Exit the loop as we found a blocker + } else { + core.info(`Found a blocking comment: PR is blocked by #${blockingPRNumber} but it is closed. So it is not blocking.`); + } + } + } + + if (!isBlocked) { + core.info('PR is not blocked by any PR mentioned in comments.'); + } + + } catch (error) { + core.setFailed(`Action failed with error ${error}`); + } +} + +run(); \ No newline at end of file diff --git a/check-pr-blockage/package-lock.json b/check-pr-blockage/package-lock.json new file mode 100644 index 0000000..0d8788e --- /dev/null +++ b/check-pr-blockage/package-lock.json @@ -0,0 +1,215 @@ +{ + "name": "check-pr-blockage", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@actions/core": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", + "requires": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + } + }, + "@actions/github": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz", + "integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==", + "requires": { + "@actions/http-client": "^2.0.1", + "@octokit/core": "^3.6.0", + "@octokit/plugin-paginate-rest": "^2.17.0", + "@octokit/plugin-rest-endpoint-methods": "^5.13.0" + } + }, + "@actions/http-client": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz", + "integrity": "sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==", + "requires": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, + "@fastify/busboy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", + "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==" + }, + "@octokit/auth-token": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", + "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", + "requires": { + "@octokit/types": "^6.0.3" + } + }, + "@octokit/core": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", + "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", + "requires": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.6.3", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/endpoint": { + "version": "6.0.12", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", + "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", + "requires": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/graphql": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", + "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", + "requires": { + "@octokit/request": "^5.6.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/openapi-types": { + "version": "12.11.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", + "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" + }, + "@octokit/plugin-paginate-rest": { + "version": "2.21.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz", + "integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==", + "requires": { + "@octokit/types": "^6.40.0" + } + }, + "@octokit/plugin-rest-endpoint-methods": { + "version": "5.16.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz", + "integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==", + "requires": { + "@octokit/types": "^6.39.0", + "deprecation": "^2.3.1" + } + }, + "@octokit/request": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", + "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", + "requires": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.1.0", + "@octokit/types": "^6.16.1", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.7", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/request-error": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", + "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", + "requires": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "@octokit/types": { + "version": "6.41.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", + "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", + "requires": { + "@octokit/openapi-types": "^12.11.0" + } + }, + "before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" + }, + "deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + }, + "undici": { + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", + "requires": { + "@fastify/busboy": "^2.0.0" + } + }, + "universal-user-agent": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", + "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==" + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + } + } +} diff --git a/check-pr-blockage/package.json b/check-pr-blockage/package.json new file mode 100644 index 0000000..3abe52f --- /dev/null +++ b/check-pr-blockage/package.json @@ -0,0 +1,10 @@ +{ + "name": "check-pr-blockage", + "version": "1.0.0", + "description": "", + "main": "index.js", + "dependencies": { + "@actions/core": "^1.6.0", + "@actions/github": "^5.0.0" + } +} diff --git a/create-pr-action/action.yml b/create-pr-action/action.yml new file mode 100644 index 0000000..96836cc --- /dev/null +++ b/create-pr-action/action.yml @@ -0,0 +1,16 @@ +name: 'Check Fork Status and Create PR' +description: 'Checks if the repository is a fork and creates a PR with fork status.' +runs: + using: 'node20' + main: 'index.js' +inputs: + github-token: + description: 'GitHub token for authentication' + required: true + excluded-repos: + description: 'Comma-separated list of repositories to exclude' + required: true + default: '' +outputs: + pr-url: + description: 'URL of the created Pull Request' \ No newline at end of file diff --git a/create-pr-action/index.js b/create-pr-action/index.js new file mode 100644 index 0000000..4d6f4bc --- /dev/null +++ b/create-pr-action/index.js @@ -0,0 +1,213 @@ +const core = require('@actions/core'); +const github = require('@actions/github'); + +async function run() { + try { + const token = core.getInput('github-token', { required: true }); + const excludedRepos = core.getInput('excluded-repos').split(',').map(repo => repo.trim()); + const octokit = github.getOctokit(token); + const { owner, repo } = github.context.repo; + + console.log(`Action started for repo: ${owner}/${repo}`); + + const repoFullName = `${owner}/${repo}`; + console.log(`Fetching fork parent repo info for: ${repoFullName}`); + const forkStatus = await fetchForkParentRepoInfo(repoFullName, token, excludedRepos); + + if (forkStatus !== '{}') { + console.log(`Creating PR for repo: ${repoFullName} with fork status: ${forkStatus}`); + const { url: prUrl, number: prNumber } = await createPr(repoFullName, forkStatus, token, octokit); + if (prUrl && prNumber) { + core.setOutput('pr-url', prUrl); + console.log(`PR created: ${prUrl}`); + + const blockMessage = `Blocked by #${prNumber}`; + await updateOtherPrs(owner, repo, prNumber, blockMessage, octokit); + } else { + console.log('Failed to create PR due to an error.'); + } + } else { + console.log('Repository is not a fork or is the specified repository. No PR created.'); + } + } catch (error) { + console.log(`Action failed with error: ${error}`); + core.setFailed(`Action failed with error: ${error}`); + } +} + +async function fetchForkParentRepoInfo(repoFullName, token, excludedRepos) { + const fetch = (await import('node-fetch')).default; + const api_url = `https://api.github.com/repos/${repoFullName}`; + console.log(`Fetching repo info from GitHub API: ${api_url}`); + const response = await fetch(api_url, { + headers: { + Accept: 'application/vnd.github+json', + Authorization: `Bearer ${token}`, + 'X-GitHub-Api-Version': '2022-11-28', + }, + }); + const data = await response.json(); + if (data.fork) { + const parentName = data.parent.full_name; + console.log(`Repo is a fork. Parent repo: ${parentName}`); + if (excludedRepos.includes(repoFullName)) { + return '{}'; + } else { + return `{"parent": "${parentName}"}`; + } + } + console.log('Repo is not a fork.'); + return '{}'; +} + +async function createPr(repoFullName, forkStatus, token, octokit) { + const [owner, repo] = repoFullName.split('/'); + const newBranch = `update-fork-status-2`; + const fileName = '.upstream'; + const targetBranch = 'main'; + const commitMessage = 'Update fork status'; + + console.log(`Starting PR creation process for ${repoFullName}`); + + try { + let branchExists = true; + try { + await octokit.rest.repos.getBranch({ + owner, + repo, + branch: newBranch, + }); + console.log(`Branch ${newBranch} already exists.`); + } catch (error) { + if (error.status === 404) { + branchExists = false; + console.log(`Branch ${newBranch} does not exist. Creating new branch.`); + const { data: baseBranchData } = await octokit.rest.repos.getBranch({ + owner, + repo, + branch: targetBranch, + }); + const branchSha = baseBranchData.commit.sha; + + await octokit.rest.git.createRef({ + owner, + repo, + ref: `refs/heads/${newBranch}`, + sha: branchSha, + }); + console.log(`Branch ${newBranch} created successfully.`); + } else { + throw error; + } + } + + let fileSha = ''; + if (branchExists) { + try { + const { data: fileData } = await octokit.rest.repos.getContent({ + owner, + repo, + path: fileName, + ref: newBranch, + }); + fileSha = fileData.sha; + } catch (error) { + if (error.status !== 404) { + throw error; // Rethrow if error is not due to file non-existence + } + } + } + + const contentEncoded = Buffer.from(forkStatus).toString('base64'); + const fileParams = { + owner, + repo, + path: fileName, + message: commitMessage, + content: contentEncoded, + branch: newBranch, + }; + if (fileSha) fileParams.sha = fileSha; // Only include SHA if file exists + + await octokit.rest.repos.createOrUpdateFileContents(fileParams); + + const { data: pr } = await octokit.rest.pulls.create({ + owner, + repo, + title: commitMessage, + head: newBranch, + base: targetBranch, + body: 'Automatically updating fork status', + }); + + console.log(`PR created: ${pr.html_url}`); + return { url: pr.html_url, number: pr.number }; + + } catch (error) { + console.log(`Failed to create PR: ${error.message}`); + core.setFailed(`Failed to create PR: ${error.message}`); + return { url: null, number: null }; + } +} + + +async function updateOtherPrs(owner, repo, excludedPrNumber, newBlockRefNum, octokit) { + try { + const { data: prs } = await octokit.rest.pulls.list({ + owner, + repo, + state: 'open', + }); + + const newBlockMessage = `Blocked by #${excludedPrNumber}`; + + for (const pr of prs) { + if (pr.number !== excludedPrNumber) { + console.log(`Checking PR #${pr.number} with body: ${pr.body}`); + let newBody; + // Improved regex to match variations in formatting + const blockedByRegex = /Blocked by *#\s*\d+/g; + const existingBlockMessages = pr.body.match(blockedByRegex); + console.log(`Existing block message match for PR #${pr.number}: ${existingBlockMessages}`); + + if (existingBlockMessages && existingBlockMessages.length > 0) { + // Replace the first occurrence of the block message + console.log(`Replacing ${existingBlockMessages} with ${newBlockMessage}`); + newBody = pr.body.replace(existingBlockMessages, newBlockMessage); + // Remove any additional block messages that might exist + newBody = newBody.replace(new RegExp(existingBlockMessages, 'g'), ''); + } else { + newBody = `${pr.body}\n\n${newBlockMessage}`; + } + + console.log(`Updating PR #${pr.number} body to: ${newBody}`); + await updatePrBody(owner, repo, pr.number, newBody, octokit); + console.log(`Updated PR #${pr.number} body.`); + await postCommentToPr(owner, repo, pr.number, `This PR is now ${newBlockMessage}.`, octokit); + } + } + } catch (error) { + console.log(`Failed to update other PRs: ${error.message}`); + core.setFailed(`Failed to update other PRs: ${error.message}`); + } +} + +async function postCommentToPr(owner, repo, prNumber, comment, octokit) { + await octokit.rest.issues.createComment({ + owner, + repo, + issue_number: prNumber, + body: comment, + }); +} + +async function updatePrBody(owner, repo, prNumber, newBody, octokit) { + await octokit.rest.pulls.update({ + owner, + repo, + pull_number: prNumber, + body: newBody, + }); +} + +run(); \ No newline at end of file diff --git a/create-pr-action/package-lock.json b/create-pr-action/package-lock.json new file mode 100644 index 0000000..49b5895 --- /dev/null +++ b/create-pr-action/package-lock.json @@ -0,0 +1,50 @@ +{ + "name": "check-pr-blockage", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==" + }, + "fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "requires": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + } + }, + "formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "requires": { + "fetch-blob": "^3.1.2" + } + }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" + }, + "node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "requires": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + } + }, + "web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==" + } + } +} diff --git a/create-pr-action/package.json b/create-pr-action/package.json new file mode 100644 index 0000000..c209734 --- /dev/null +++ b/create-pr-action/package.json @@ -0,0 +1,11 @@ +{ + "name": "check-pr-blockage", + "version": "1.0.0", + "description": "", + "main": "index.js", + "dependencies": { + "@actions/core": "^1.6.0", + "@actions/github": "^5.0.0", + "node-fetch": "^3.3.2" + } +}