Skip to content

Commit 02f2004

Browse files
gfraiteurclaude
andcommitted
Add GitHub CLI component to Claude Docker container
Automatically installs gh CLI when ClaudeComponent is enabled, enabling GitHub workflows (PRs, issues, releases) from within the container. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 8392442 commit 02f2004

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

Dockerfile.claude

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ RUN Invoke-WebRequest -Uri "https://nodejs.org/dist/v22.0.0/node-v22.0.0-win-x64
6868
ENV PATH="C:\nodejs;${PATH}"
6969

7070

71+
# Install GitHub CLI
72+
RUN Invoke-WebRequest -Uri https://github.com/cli/cli/releases/download/v2.63.2/gh_2.63.2_windows_amd64.msi -OutFile gh.msi; `
73+
$process = Start-Process msiexec.exe -Wait -PassThru -ArgumentList '/I gh.msi /quiet'; `
74+
if ($process.ExitCode -ne 0) { exit $process.ExitCode }; `
75+
Remove-Item gh.msi
76+
77+
# Add GitHub CLI to PATH using ENV directive (persists across shell switches)
78+
ENV PATH="C:\Program Files\GitHub CLI;${PATH}"
79+
80+
7181
# Install Claude CLI
7282
# Configure npm global directory to avoid Windows container path issues
7383
ENV NPM_CONFIG_PREFIX=C:\npm

src/PostSharp.Engineering.BuildTools/Docker/ClaudeComponent.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,11 @@ public override void AddRequirements( IReadOnlyList<ContainerComponent> componen
4848
throw new InvalidOperationException(
4949
$"Claude CLI requires Node.js >= {_minNodeVersion}, but {existingNodeJs.Version} is configured." );
5050
}
51+
52+
// Auto-add GitHubCliComponent if not already present
53+
if ( !components.OfType<GitHubCliComponent>().Any() )
54+
{
55+
add( new GitHubCliComponent() );
56+
}
5157
}
5258
}

src/PostSharp.Engineering.BuildTools/Docker/ContainerComponentKind.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum ContainerComponentKind
1717
NodeJs,
1818
Python,
1919
Gulp,
20+
GitHubCli,
2021
Claude,
2122
Epilogue
2223
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using JetBrains.Annotations;
4+
using System.IO;
5+
6+
namespace PostSharp.Engineering.BuildTools.Docker;
7+
8+
[PublicAPI]
9+
public sealed class GitHubCliComponent : ContainerComponent
10+
{
11+
public override string Name => "Install GitHub CLI";
12+
13+
public override ContainerComponentKind Kind => ContainerComponentKind.GitHubCli;
14+
15+
public override void WriteDockerfile( TextWriter writer )
16+
{
17+
writer.WriteLine(
18+
"""
19+
RUN Invoke-WebRequest -Uri https://github.com/cli/cli/releases/download/v2.63.2/gh_2.63.2_windows_amd64.msi -OutFile gh.msi; `
20+
$process = Start-Process msiexec.exe -Wait -PassThru -ArgumentList '/I gh.msi /quiet'; `
21+
if ($process.ExitCode -ne 0) { exit $process.ExitCode }; `
22+
Remove-Item gh.msi
23+
24+
# Add GitHub CLI to PATH using ENV directive (persists across shell switches)
25+
ENV PATH="C:\Program Files\GitHub CLI;${PATH}"
26+
""" );
27+
}
28+
}

0 commit comments

Comments
 (0)