-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpoe-code-github-pull-request-opened.yml
More file actions
114 lines (113 loc) · 4.42 KB
/
poe-code-github-pull-request-opened.yml
File metadata and controls
114 lines (113 loc) · 4.42 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
# Auto-generated by: poe-code github-workflows install github-pull-request-opened
name: 'GitHub: Pull Request Opened'
on:
pull_request:
types: [opened, ready_for_review]
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-pull-request-opened
env:
POE_CODE_STDERR_LOGS: "1"
COMMENT_AUTHOR_ASSOCIATION: ${{ github.event.pull_request.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: read
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-pull-request-opened
env:
POE_CODE_STDERR_LOGS: "1"
POE_API_KEY: ${{ secrets.POE_API_KEY }}
- run: poe-code github-workflows github-pull-request-opened --yes
env:
POE_CODE_STDERR_LOGS: "1"
POE_API_KEY: ${{ secrets.POE_API_KEY }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
GITHUB_REPOSITORY: ${{ github.repository }}