-
Notifications
You must be signed in to change notification settings - Fork 9
133 lines (133 loc) · 4.85 KB
/
gh-github-issue-opened.yml
File metadata and controls
133 lines (133 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Generated by: packages/github-workflows/scripts/generate-gh-workflows.ts
# Source: packages/github-workflows/src/workflow-templates/github-issue-opened.ejected.yml
name: "GitHub: Issue Opened"
on:
workflow_call:
inputs:
ISSUE_NUMBER:
required: true
type: number
ISSUE_TITLE:
required: true
type: string
ISSUE_BODY:
required: true
type: string
COMMENT_AUTHOR_ASSOCIATION:
required: true
type: string
GITHUB_REPOSITORY:
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ inputs.ISSUE_NUMBER }}
cancel-in-progress: true
jobs:
guard:
runs-on: ubuntu-latest
env:
OUTPUT_FORMAT: terminal
outputs:
should_run: ${{ steps.guard_result.outputs.should_run }}
permissions:
contents: read
steps:
- name: Preflight
env:
POE_CODE_AGENT_APP_ID: ${{ secrets.POE_CODE_AGENT_APP_ID }}
POE_CODE_AGENT_PRIVATE_KEY: ${{ secrets.POE_CODE_AGENT_PRIVATE_KEY }}
POE_API_KEY: ${{ secrets.POE_API_KEY }}
run: |
missing=()
[ -z "$POE_CODE_AGENT_APP_ID" ] && missing+=("POE_CODE_AGENT_APP_ID")
[ -z "$POE_CODE_AGENT_PRIVATE_KEY" ] && missing+=("POE_CODE_AGENT_PRIVATE_KEY")
[ -z "$POE_API_KEY" ] && missing+=("POE_API_KEY")
if [ ${#missing[@]} -gt 0 ]; then
for name in "${missing[@]}"; do
echo "::error::Missing required secret: $name — add it in Settings → Secrets and variables → Actions"
done
exit 1
fi
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.POE_CODE_AGENT_APP_ID }}
private-key: ${{ secrets.POE_CODE_AGENT_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g poe-code@latest
- id: allow_check
continue-on-error: true
run: poe-code github-workflows require-user-allow github-issue-opened
env:
POE_CODE_STDERR_LOGS: "1"
COMMENT_AUTHOR_ASSOCIATION: ${{ inputs.COMMENT_AUTHOR_ASSOCIATION }}
- id: guard_result
run: |
if [ "${{ steps.allow_check.outcome }}" = "success" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
else
echo "should_run=false" >> "$GITHUB_OUTPUT"
fi
run:
needs: guard
if: needs.guard.outputs.should_run == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Preflight
env:
POE_CODE_AGENT_APP_ID: ${{ secrets.POE_CODE_AGENT_APP_ID }}
POE_CODE_AGENT_PRIVATE_KEY: ${{ secrets.POE_CODE_AGENT_PRIVATE_KEY }}
POE_API_KEY: ${{ secrets.POE_API_KEY }}
run: |
missing=()
[ -z "$POE_CODE_AGENT_APP_ID" ] && missing+=("POE_CODE_AGENT_APP_ID")
[ -z "$POE_CODE_AGENT_PRIVATE_KEY" ] && missing+=("POE_CODE_AGENT_PRIVATE_KEY")
[ -z "$POE_API_KEY" ] && missing+=("POE_API_KEY")
if [ ${#missing[@]} -gt 0 ]; then
for name in "${missing[@]}"; do
echo "::error::Missing required secret: $name — add it in Settings → Secrets and variables → Actions"
done
exit 1
fi
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.POE_CODE_AGENT_APP_ID }}
private-key: ${{ secrets.POE_CODE_AGENT_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install -g poe-code@latest
- name: Configure git identity for GitHub App
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
run: |
USER_ID=$(gh api "/users/${APP_SLUG}[bot]" --jq .id)
git config --global user.name "${APP_SLUG}[bot]"
git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
- run: poe-code github-workflows prepare github-issue-opened
env:
POE_CODE_STDERR_LOGS: "1"
POE_API_KEY: ${{ secrets.POE_API_KEY }}
- run: poe-code github-workflows github-issue-opened --yes
env:
POE_CODE_STDERR_LOGS: "1"
POE_API_KEY: ${{ secrets.POE_API_KEY }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
ISSUE_NUMBER: ${{ inputs.ISSUE_NUMBER }}
ISSUE_TITLE: ${{ inputs.ISSUE_TITLE }}
ISSUE_BODY: ${{ inputs.ISSUE_BODY }}
GITHUB_REPOSITORY: ${{ inputs.GITHUB_REPOSITORY }}