Skip to content

Commit

Permalink
feat: bugfix2
Browse files Browse the repository at this point in the history
  • Loading branch information
rockyj committed Jan 9, 2025
1 parent 0c3584c commit 72e64fe
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions .github/workflows/approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
issue_comment:
types: [created]

# 添加权限配置
permissions:
contents: read
issues: write
pull-requests: write

jobs:
approval:
if: |
Expand All @@ -16,28 +22,39 @@ jobs:
github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Debug Event
run: |
echo "Event name: ${{ github.event_name }}"
echo "Ref: ${{ github.ref }}"
echo "SHA: ${{ github.sha }}"
- name: Create Deployment Issue
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚀 Deployment Approval Required',
body: `
### Deployment Approval Request
- Commit: ${context.sha}
- Triggered by: @${context.actor}
- Branch: ${context.ref}
- Event: ${context.eventName}
To approve this deployment, a maintainer must comment with \`confirm\`
`
});
console.log(`Created approval issue #${issue.data.number}`);
try {
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚀 Deployment Approval Required',
body: `
### Deployment Approval Request
- Commit: ${context.sha}
- Triggered by: @${context.actor}
- Branch: ${context.ref}
- Event: ${context.eventName}
To approve this deployment, a maintainer must comment with \`confirm\`
`
});
console.log('Successfully created issue:', issue.data.html_url);
} catch (error) {
console.error('Error creating issue:', error);
core.setFailed(error.message);
}
- name: Check Approver Permission
if: github.event_name == 'issue_comment'
Expand Down

0 comments on commit 72e64fe

Please sign in to comment.