-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
105 lines (98 loc) · 3.5 KB
/
action.yml
File metadata and controls
105 lines (98 loc) · 3.5 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
name: "GMC - Git Message Commit"
description: "Generate high-quality commit messages using LLM"
author: "samzong"
branding:
icon: "edit-3"
color: "purple"
inputs:
args:
description: "Extra args for generate mode (e.g. '-a --issue 123 --branch ""add auth""')"
required: false
default: ""
apikey:
description: "OpenAI API key for LLM"
required: false
apibase:
description: "OpenAI API Base URL (proxy)"
required: false
model:
description: "LLM model (e.g. gpt-4.1-mini)"
required: false
role:
description: "Role context for message generation"
required: false
prompt_template:
description: "Prompt template name (in prompts_dir)"
required: false
working-directory:
description: "Working directory to run commands in"
required: false
default: "."
comment:
description: "If true on PRs, post generation output as a comment"
required: false
default: "false"
outputs:
report:
description: "Full text output from generate run"
value: ${{ steps.run.outputs.report }}
commit_message:
description: "Generated commit message (typically with --dry-run)"
value: ${{ steps.run.outputs.commit_message }}
runs:
using: "composite"
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
- name: Build gmc
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
set -euo pipefail
echo "Building gmc binary..."
go build -trimpath -o gmc .
- name: Configure gmc
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
set -euo pipefail
if [ -n "${{ inputs.apikey }}" ]; then ./gmc config set apikey "${{ inputs.apikey }}"; fi
if [ -n "${{ inputs.apibase }}" ]; then ./gmc config set apibase "${{ inputs.apibase }}"; fi
if [ -n "${{ inputs.model }}" ]; then ./gmc config set model "${{ inputs.model }}"; fi
if [ -n "${{ inputs.role }}" ]; then ./gmc config set role "${{ inputs.role }}"; fi
if [ -n "${{ inputs.prompt_template }}" ]; then ./gmc config set prompt_template "${{ inputs.prompt_template }}"; fi
- name: Run GMC
id: run
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
# Ensure pager/editor don't block in CI
PAGER: cat
EDITOR: true
VISUAL: true
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP"
echo "Running: ./gmc -y --dry-run ${{ inputs.args }}"
if ! OUT=$(./gmc -y --dry-run ${{ inputs.args }} 2>&1); then
echo "gmc generate returned non-zero; continuing and capturing output"
fi
printf "%s\n" "$OUT" | sed -e 's/\r$//' > "$RUNNER_TEMP/gmc_output.txt"
printf 'report<<EOF\n%s\nEOF\n' "$OUT" >> "$GITHUB_OUTPUT"
printf 'commit_message<<EOF\n%s\nEOF\n' "$OUT" >> "$GITHUB_OUTPUT"
- name: Comment on PR with output
if: ${{ inputs.comment == 'true' && startsWith(github.event_name, 'pull_request') }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = process.env.RUNNER_TEMP + '/gmc_output.txt';
const body = fs.readFileSync(path, 'utf8');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body.length > 65000 ? body.slice(0, 65000) + '\n\n…(truncated)…' : body,
});