-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from opencepk/feat/githubaction-custom
custom git actions
- Loading branch information
Showing
9 changed files
with
679 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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,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 |
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,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(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,10 @@ | ||
{ | ||
"name": "check-pr-blockage", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@actions/core": "^1.6.0", | ||
"@actions/github": "^5.0.0" | ||
} | ||
} |
Oops, something went wrong.