-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (172 loc) · 7.44 KB
/
Copy pathopencode.yml
File metadata and controls
178 lines (172 loc) · 7.44 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: OpenCode
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
concurrency:
group: opencode-${{ github.repository }}-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: false
permissions:
contents: read
jobs:
authorize:
if: >-
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR') &&
(startsWith(github.event.comment.body, '/oc ') ||
startsWith(github.event.comment.body, '/opencode '))
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read
issues: read
pull-requests: read
outputs:
mode: ${{ steps.command.outputs.mode }}
model: ${{ steps.command.outputs.model }}
prompt: ${{ steps.command.outputs.prompt }}
target_type: ${{ steps.target.outputs.target_type }}
target_number: ${{ steps.target.outputs.target_number }}
target_state: ${{ steps.target.outputs.target_state }}
target_updated_at: ${{ steps.target.outputs.target_updated_at }}
base_ref: ${{ steps.target.outputs.base_ref }}
head_ref: ${{ steps.target.outputs.head_ref }}
head_sha: ${{ steps.target.outputs.head_sha }}
head_repo: ${{ steps.target.outputs.head_repo }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
ref: ${{ github.event.repository.default_branch }}
- name: Parse and authorize command
id: command
run: node .github/scripts/opencode-command.mjs
- name: Require repository write access
env:
GITHUB_TOKEN: ${{ github.token }}
MODE: ${{ steps.command.outputs.mode }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: node .github/scripts/opencode-authorize-actor.mjs
- name: Authorize target
id: target
env:
GITHUB_TOKEN: ${{ github.token }}
MODE: ${{ steps.command.outputs.mode }}
run: node .github/scripts/opencode-target.mjs
plan:
if: needs.authorize.outputs.mode == 'plan'
needs: authorize
runs-on: ubuntu-24.04
timeout-minutes: 30
environment: opencode-plan
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
ref: ${{ github.event.repository.default_branch }}
- name: Install pinned OpenCode
shell: bash
run: |
set -euo pipefail
archive="$RUNNER_TEMP/opencode-linux-x64.tar.gz"
install_dir="$RUNNER_TEMP/opencode"
mkdir -p "$install_dir"
curl --fail --location --proto '=https' --tlsv1.2 \
--output "$archive" \
https://github.com/anomalyco/opencode/releases/download/v1.18.4/opencode-linux-x64.tar.gz
printf '%s %s\n' \
bab463c3fb3224d388bb7cfad63f38703df9cf0be2cfd2ce8cb49d886b53a174 \
"$archive" | sha256sum --check --strict
tar -xzf "$archive" -C "$install_dir"
"$install_dir/opencode" --version
printf '%s\n' "$install_dir" >> "$GITHUB_PATH"
- name: Configure OpenCode OAuth
env:
OPENAI_OAUTH_ACCESS_TOKEN: ${{ secrets.OPENAI_OAUTH_ACCESS_TOKEN }}
OPENAI_OAUTH_REFRESH_TOKEN: ${{ secrets.OPENAI_OAUTH_REFRESH_TOKEN }}
OPENAI_OAUTH_EXPIRES: ${{ secrets.OPENAI_OAUTH_EXPIRES }}
OPENAI_OAUTH_ACCOUNT_ID: ${{ secrets.OPENAI_OAUTH_ACCOUNT_ID }}
run: node .github/scripts/opencode-auth.mjs
- name: Run read-only OpenCode plan
env:
MODEL: ${{ needs.authorize.outputs.model }}
OPENCODE_CONFIG_CONTENT: >-
{"share":"disabled","default_agent":"github-plan","small_model":"openai/gpt-5.6-luna","enabled_providers":["openai"],"provider":{"openai":{"whitelist":["gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna"]}},"formatter":false,"lsp":false}
PROMPT: ${{ needs.authorize.outputs.prompt }}
SHARE: 'false'
run: opencode github run
build:
if: >-
needs.authorize.outputs.mode == 'build' &&
vars.OPENCODE_BUILD_ENABLED == 'true'
needs: authorize
runs-on: ubuntu-24.04
timeout-minutes: 45
environment: opencode-build
permissions:
contents: read
issues: read
pull-requests: read
id-token: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
ref: ${{ github.event.repository.default_branch }}
- name: Install pinned OpenCode
shell: bash
run: |
set -euo pipefail
archive="$RUNNER_TEMP/opencode-linux-x64.tar.gz"
install_dir="$RUNNER_TEMP/opencode"
mkdir -p "$install_dir"
curl --fail --location --proto '=https' --tlsv1.2 \
--output "$archive" \
https://github.com/anomalyco/opencode/releases/download/v1.18.4/opencode-linux-x64.tar.gz
printf '%s %s\n' \
bab463c3fb3224d388bb7cfad63f38703df9cf0be2cfd2ce8cb49d886b53a174 \
"$archive" | sha256sum --check --strict
tar -xzf "$archive" -C "$install_dir"
"$install_dir/opencode" --version
printf '%s\n' "$install_dir" >> "$GITHUB_PATH"
- name: Verify authorized target
env:
AUTHORIZED_BASE_REF: ${{ needs.authorize.outputs.base_ref }}
AUTHORIZED_HEAD_REF: ${{ needs.authorize.outputs.head_ref }}
AUTHORIZED_HEAD_REPO: ${{ needs.authorize.outputs.head_repo }}
AUTHORIZED_HEAD_SHA: ${{ needs.authorize.outputs.head_sha }}
AUTHORIZED_TARGET_STATE: ${{ needs.authorize.outputs.target_state }}
AUTHORIZED_UPDATED_AT: ${{ needs.authorize.outputs.target_updated_at }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITHUB_TOKEN: ${{ github.token }}
TARGET_NUMBER: ${{ needs.authorize.outputs.target_number }}
TARGET_TYPE: ${{ needs.authorize.outputs.target_type }}
run: node .github/scripts/opencode-verify-target.mjs
- name: Reauthorize commenter after approval
env:
GITHUB_TOKEN: ${{ github.token }}
MODE: build
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: node .github/scripts/opencode-authorize-actor.mjs
- name: Configure OpenCode OAuth
env:
OPENAI_OAUTH_ACCESS_TOKEN: ${{ secrets.OPENAI_OAUTH_ACCESS_TOKEN }}
OPENAI_OAUTH_REFRESH_TOKEN: ${{ secrets.OPENAI_OAUTH_REFRESH_TOKEN }}
OPENAI_OAUTH_EXPIRES: ${{ secrets.OPENAI_OAUTH_EXPIRES }}
OPENAI_OAUTH_ACCOUNT_ID: ${{ secrets.OPENAI_OAUTH_ACCOUNT_ID }}
run: node .github/scripts/opencode-auth.mjs
- name: Run constrained OpenCode build
env:
MODEL: ${{ needs.authorize.outputs.model }}
OPENCODE_CONFIG_CONTENT: >-
{"share":"disabled","default_agent":"github-build","small_model":"openai/gpt-5.6-luna","enabled_providers":["openai"],"provider":{"openai":{"whitelist":["gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna"]}},"formatter":false,"lsp":false}
PROMPT: ${{ needs.authorize.outputs.prompt }}
SHARE: 'false'
run: opencode github run