Skip to content

Commit

Permalink
Merge branch 'main' into scan_image_test
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/scan-image.yml
#	.idea/workspace.xml
  • Loading branch information
shishupei committed Dec 17, 2024
2 parents 65a4fba + 4890706 commit 4415f71
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
7 changes: 1 addition & 6 deletions .github/script/scan_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ DATA=$(cat <<EOF
}
,
{
"name" : "commit_cha",
"name" : "image_url",
"value" : "$9"
}
,
{
"name" : "branch",
"value" : "$1"
}
]
}
EOF
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/scan-image.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
name: PR Comment Trigger - Scan Image
name: Process PR Comment and Run Script

on:
issue_comment:
types: [created]
types: [created] # 仅当评论被创建时触发

jobs:
scan_image:
process_comment:
runs-on: ubuntu-latest

steps:
- name: Check if comment is "扫描镜像"
if: |
github.event.comment.body == '扫描镜像'
run: ./.github/script/scan_image.sh $GITHUB_HEAD_REF ${{ github.event.pull_request.number }} ${{ secrets.CODEARTS_PASSWORD }} ${{ secrets.CODEARTS_SCAN_IMAGE_PIPELINE }} ${{ secrets.CODEARTS_ENDPOINT_ID }} $GIT_URL ${GITHUB_REPOSITORY%/*} ${GITHUB_REPOSITORY##*/} ${{ github.event.pull_request.head.sha }}
- name: Display original comment content
run: |
echo "Original comment: ${{ github.event.comment.body }}"
- 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 "Prefix matched. Running script with parameter: $IMAGE_URL"
# 执行 aaa.sh 脚本并将参数传递给脚本
./.github/script/scan_image.sh $GITHUB_HEAD_REF ${{ github.event.pull_request.number }} ${{ secrets.CODEARTS_PASSWORD }} ${{ secrets.CODEARTS_SCAN_IMAGE_PIPELINE }} ${{ secrets.CODEARTS_ENDPOINT_ID }} $GIT_URL ${GITHUB_REPOSITORY%/*} ${GITHUB_REPOSITORY##*/} "$IMAGE_URL"
else
echo "Comment does not match the prefix, skipping the script execution."
fi
37 changes: 4 additions & 33 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4415f71

Please sign in to comment.