mirror of
https://github.com/markwylde/claude-code-gitea-action.git
synced 2026-08-21 23:45:11 +08:00
fix: support pinned local base action
This commit is contained in:
@@ -61,6 +61,10 @@ inputs:
|
|||||||
description: "Timeout in minutes for Claude Code execution"
|
description: "Timeout in minutes for Claude Code execution"
|
||||||
required: false
|
required: false
|
||||||
default: "10"
|
default: "10"
|
||||||
|
path_to_claude_code_executable:
|
||||||
|
description: "Path to a custom Claude Code executable to use instead of installing"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
# Authentication settings
|
# Authentication settings
|
||||||
anthropic_api_key:
|
anthropic_api_key:
|
||||||
@@ -114,11 +118,21 @@ runs:
|
|||||||
bun install
|
bun install
|
||||||
|
|
||||||
- name: Install Claude Code
|
- name: Install Claude Code
|
||||||
|
if: inputs.path_to_claude_code_executable == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.173
|
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.173
|
||||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: Use custom Claude Code executable
|
||||||
|
if: inputs.path_to_claude_code_executable != ''
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CLAUDE_CODE_EXECUTABLE: ${{ inputs.path_to_claude_code_executable }}
|
||||||
|
run: |
|
||||||
|
echo "Using custom Claude Code executable: $CLAUDE_CODE_EXECUTABLE"
|
||||||
|
echo "$(dirname "$CLAUDE_CODE_EXECUTABLE")" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
- name: Run Claude Code Action
|
- name: Run Claude Code Action
|
||||||
shell: bash
|
shell: bash
|
||||||
id: run_claude
|
id: run_claude
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
|
||||||
|
import * as core from "@actions/core";
|
||||||
|
import { setupGitHubToken } from "../src/github/token";
|
||||||
|
|
||||||
|
describe("setupGitHubToken", () => {
|
||||||
|
const originalEnv = { ...process.env };
|
||||||
|
let setOutputSpy: ReturnType<typeof spyOn>;
|
||||||
|
let logSpy: ReturnType<typeof spyOn>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
delete process.env.OVERRIDE_GITHUB_TOKEN;
|
||||||
|
delete process.env.GITHUB_TOKEN;
|
||||||
|
setOutputSpy = spyOn(core, "setOutput").mockImplementation(() => {});
|
||||||
|
logSpy = spyOn(console, "log").mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
setOutputSpy.mockRestore();
|
||||||
|
logSpy.mockRestore();
|
||||||
|
process.env = { ...originalEnv };
|
||||||
|
});
|
||||||
|
|
||||||
|
test("prefers the explicit Gitea token", async () => {
|
||||||
|
process.env.OVERRIDE_GITHUB_TOKEN = "gitea-token";
|
||||||
|
process.env.GITHUB_TOKEN = "workflow-token";
|
||||||
|
|
||||||
|
expect(await setupGitHubToken()).toBe("gitea-token");
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith("GITHUB_TOKEN", "gitea-token");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("falls back to the workflow token without requesting OIDC", async () => {
|
||||||
|
process.env.GITHUB_TOKEN = "workflow-token";
|
||||||
|
|
||||||
|
expect(await setupGitHubToken()).toBe("workflow-token");
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith("GITHUB_TOKEN", "workflow-token");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user