-
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.
- Loading branch information
1 parent
d86ad2d
commit c523894
Showing
2 changed files
with
69 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Check Branch Naming for PRs | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
check-branch-naming: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check PR source branch against target branch | ||
run: | | ||
# 获取目标分支和源分支 | ||
TARGET_BRANCH="${{ github.base_ref }}" | ||
SOURCE_BRANCH="${{ github.head_ref }}" | ||
echo "Target branch: $TARGET_BRANCH" | ||
echo "Source branch: $SOURCE_BRANCH" | ||
# 检查目标分支是否是 default 分支 (main/master) | ||
if [[ "$TARGET_BRANCH" == "${{ github.event.repository.default_branch }}" ]]; then | ||
if [[ ! "$SOURCE_BRANCH" =~ ^release/.* ]]; then | ||
echo "Error: The source branch must be of the form 'release/*' when merging into the default branch." | ||
exit 1 | ||
fi | ||
# 检查目标分支是否是 release/* | ||
elif [[ "$TARGET_BRANCH" =~ ^release/.* ]]; then | ||
if [[ ! "$SOURCE_BRANCH" =~ ^(feature|bugfix)/.* ]]; then | ||
echo "Error: The source branch must be of the form 'feature/*' or 'bugfix/*' when merging into 'release/*'." | ||
exit 1 | ||
fi | ||
fi |
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,33 @@ | ||
name: Process PR Comment and Run Script | ||
|
||
on: | ||
issue_comment: | ||
types: [created] # 仅当评论被创建时触发 | ||
|
||
jobs: | ||
process_comment: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Make script executable | ||
run: chmod +x ./.github/script/scan_image.sh | ||
|
||
- name: Check if comment has the specified prefix and run script | ||
run: | | ||
# 获取评论内容 | ||
COMMENT_BODY="${{ github.event.comment.body }}" | ||
PREFIX="扫描镜像:" | ||
# 判断评论是否包含指定的前缀 | ||
if [[ "$COMMENT_BODY" == "$PREFIX"* ]]; then | ||
# 去掉前缀并提取后面的内容 | ||
IMAGE_URL="${COMMENT_BODY#$PREFIX}" | ||
echo "main" ${{ github.event.issue.number }} ${{ secrets.CODEARTS_PASSWORD }} ${{ secrets.CODEARTS_SCAN_IMAGE_PIPELINE }} ${{ secrets.CODEARTS_ENDPOINT_ID }} "https://github.com/${GITHUB_REPOSITORY}.git" ${GITHUB_REPOSITORY%/*} ${GITHUB_REPOSITORY##*/} "$IMAGE_URL" | ||
./.github/script/scan_image.sh "main" ${{ github.event.issue.number }} ${{ secrets.CODEARTS_PASSWORD }} ${{ secrets.CODEARTS_SCAN_IMAGE_PIPELINE }} ${{ secrets.CODEARTS_ENDPOINT_ID }} "https://github.com/${GITHUB_REPOSITORY}.git" ${GITHUB_REPOSITORY%/*} ${GITHUB_REPOSITORY##*/} "$IMAGE_URL" | ||
else | ||
echo "Comment does not match the prefix, skipping the script execution." | ||
fi |