Skip to content

Commit 407a73d

Browse files
committed
feat: create SVN container
0 parents  commit 407a73d

File tree

14 files changed

+548
-0
lines changed

14 files changed

+548
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.git
2+
*.md
3+
node_modules
4+
build
5+
dist
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Example usage
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
example:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Use svn-binary
12+
uses: ./
13+
with:
14+
version: latest
15+
16+
- name: Check svn version
17+
run: svn --version
18+
19+
- name: Cleanup svn container
20+
run: |
21+
chmod +x scripts/cleanup.sh
22+
scripts/cleanup.sh

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build and publish image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v2
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Login to GHCR
21+
uses: docker/login-action@v2
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Build and push
28+
uses: docker/build-push-action@v4
29+
with:
30+
push: true
31+
tags: |
32+
ghcr.io/${{ github.repository_owner }}/svn-binary:${{ github.ref_name }}
33+
ghcr.io/${{ github.repository_owner }}/svn-binary:latest

.github/workflows/smoke-test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Smoke test
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
smoke:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Start svn container via action
13+
uses: ./
14+
with:
15+
version: latest
16+
17+
- name: svn --version
18+
run: svn --version
19+
20+
- name: Cleanup
21+
run: |
22+
chmod +x scripts/cleanup.sh
23+
scripts/cleanup.sh

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
dist

CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Contributing to svn-binary
2+
3+
Thank you for your interest in contributing to svn-binary. This document provides guidelines and instructions for contributing to the project.
4+
5+
## Code of Conduct
6+
7+
By participating in this project, you agree to maintain a professional and respectful environment for all contributors.
8+
9+
## How to Contribute
10+
11+
### Reporting Issues
12+
13+
When reporting issues, please include:
14+
15+
- A clear and descriptive title
16+
- Detailed steps to reproduce the problem
17+
- Expected behavior vs. actual behavior
18+
- Environment details (runner OS, Docker version, GitHub Actions version)
19+
- Relevant logs or error messages
20+
21+
### Suggesting Enhancements
22+
23+
Enhancement suggestions are welcome. Please provide:
24+
25+
- A clear description of the proposed feature
26+
- Use cases and benefits
27+
- Potential implementation approach (if applicable)
28+
29+
### Pull Requests
30+
31+
1. **Fork the repository** and create your branch from `main`
32+
2. **Make your changes** following the coding standards below
33+
3. **Test your changes** thoroughly
34+
4. **Update documentation** as needed (README, inline comments)
35+
5. **Commit with clear messages** describing the changes
36+
6. **Submit a pull request** with a comprehensive description
37+
38+
### Coding Standards
39+
40+
- Use clear, descriptive variable and function names
41+
- Add comments for complex logic
42+
- Follow existing code style and formatting
43+
- Ensure all shell scripts are POSIX-compliant where possible
44+
- Test on Linux (ubuntu-latest) runners
45+
46+
### Testing
47+
48+
Before submitting a pull request:
49+
50+
1. Build the Docker image locally:
51+
```bash
52+
docker build -t svn-binary:test .
53+
```
54+
55+
2. Test the action locally (requires [act](https://github.com/nektos/act)):
56+
```bash
57+
act workflow_dispatch -W .github/workflows/smoke-test.yml
58+
```
59+
60+
3. Verify the `svn` command works:
61+
```bash
62+
docker run --rm svn-binary:test --version
63+
```
64+
65+
### Development Workflow
66+
67+
1. Clone your fork locally
68+
2. Create a feature branch: `git checkout -b feature/your-feature-name`
69+
3. Make changes and test thoroughly
70+
4. Commit: `git commit -m "Description of changes"`
71+
5. Push: `git push origin feature/your-feature-name`
72+
6. Open a pull request against the `main` branch
73+
74+
## Release Process
75+
76+
Releases are managed by maintainers:
77+
78+
1. Update version in relevant files
79+
2. Update CHANGELOG.md with release notes
80+
3. Create a GitHub release with appropriate tags
81+
4. The CI/CD pipeline automatically builds and publishes container images
82+
83+
## Questions?
84+
85+
For questions not covered here, please open an issue with the `question` label.
86+
87+
## License
88+
89+
By contributing, you agree that your contributions will be licensed under the MIT License.

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM debian:bookworm-slim
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update \
6+
&& apt-get install -y --no-install-recommends ca-certificates curl gnupg dirmngr \
7+
&& apt-get install -y --no-install-recommends subversion \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
ENTRYPOINT ["/usr/bin/svn"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Code Snippets Pro
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# svn-binary
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4+
[![GitHub Release](https://img.shields.io/github/v/release/codesnippetspro/svn-binary)](https://github.com/codesnippetspro/svn-binary/releases)
5+
6+
A GitHub Action that provides the Subversion (SVN) command-line interface in CI/CD workflows by running a containerized SVN installation and exposing it to the runner PATH.
7+
8+
## Overview
9+
10+
This action eliminates the need to install Subversion on every workflow run by leveraging a pre-built Docker container. The container runs as a background service, and a lightweight wrapper script forwards `svn` commands to the containerized binary via `docker exec`.
11+
12+
### Key Benefits
13+
14+
- **Reduced build time**: Avoids repeated `apt-get install` operations on every workflow run
15+
- **Consistent environment**: Uses a fixed Subversion version from a controlled container image
16+
- **Minimal overhead**: Container images are cached by GitHub Actions infrastructure
17+
- **Drop-in replacement**: Existing `svn` commands work without modification
18+
19+
## Installation
20+
21+
Add the action to your workflow:
22+
23+
```yaml
24+
- name: Install SVN Binary
25+
uses: codesnippetspro/svn-binary@v1
26+
```
27+
28+
## Usage
29+
30+
### Basic Usage
31+
32+
Use the default latest version:
33+
34+
```yaml
35+
- name: Install SVN Binary
36+
uses: codesnippetspro/svn-binary@v1
37+
38+
- name: Run SVN commands
39+
run: |
40+
svn --version
41+
svn checkout https://svn.example.com/repo/trunk
42+
```
43+
44+
### Specify Version
45+
46+
Pin to a specific version:
47+
48+
```yaml
49+
- name: Install SVN Binary
50+
uses: codesnippetspro/svn-binary@v1
51+
with:
52+
version: v1.0.0
53+
```
54+
55+
### Complete Workflow Example
56+
57+
```yaml
58+
name: Deploy to SVN Repository
59+
60+
on:
61+
release:
62+
types: [published]
63+
64+
jobs:
65+
deploy:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
71+
- name: Install SVN Binary
72+
uses: codesnippetspro/svn-binary@v1
73+
with:
74+
version: latest
75+
76+
- name: Deploy to SVN
77+
env:
78+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
79+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
80+
run: |
81+
svn checkout https://plugins.svn.example.org/my-plugin svn-repo
82+
cp -r dist/* svn-repo/trunk/
83+
cd svn-repo
84+
svn add . --force
85+
svn commit -m "Release ${{ github.ref_name }}" \
86+
--username "$SVN_USERNAME" \
87+
--password "$SVN_PASSWORD" \
88+
--no-auth-cache \
89+
--non-interactive
90+
```
91+
92+
## Configuration
93+
94+
### Inputs
95+
96+
| Input | Description | Required | Default |
97+
|-------|-------------|----------|---------|
98+
| `version` | Container image version tag (e.g., `v1.0.0`, `latest`) | No | `latest` |
99+
| `image` | Full container image path (overrides version-based image selection) | No | `ghcr.io/{owner}/svn-binary:{version}` |
100+
| `container_name` | Container name prefix (unique suffix appended automatically) | No | `svn-binary-svc` |
101+
102+
### Outputs
103+
104+
This action does not produce outputs. After execution, the `svn` command is available in the runner PATH for subsequent workflow steps.
105+
106+
## Requirements
107+
108+
- Docker must be available on the runner (pre-installed on GitHub-hosted `ubuntu-latest` runners)
109+
- Network access to GitHub Container Registry (ghcr.io) for image pulls
110+
- Sufficient runner permissions to execute `docker run` and `docker exec`
111+
112+
## Architecture
113+
114+
The action performs the following operations:
115+
116+
1. **Container Launch**: Starts a detached Docker container running `sleep infinity`
117+
2. **Wrapper Creation**: Generates a shell script at `$RUNNER_TEMP/svn-bin/svn` that forwards commands to the container via `docker exec`
118+
3. **PATH Modification**: Appends the wrapper directory to `$GITHUB_PATH` for subsequent steps
119+
120+
The container uses a unique name based on the GitHub run ID to prevent conflicts in concurrent workflows.
121+
122+
## Limitations
123+
124+
- **Docker dependency**: Requires Docker on the runner; not compatible with runners lacking Docker support
125+
- **Network overhead**: First run or cache miss requires pulling the container image (typically 50-150 MB)
126+
- **Linux only**: Designed for Linux runners; macOS and Windows support not tested
127+
- **Container lifecycle**: The container runs for the duration of the workflow job; manual cleanup may be required if the job terminates abnormally
128+
129+
## Development
130+
131+
### Building Locally
132+
133+
```bash
134+
# Build the container image
135+
docker build -t svn-binary:local .
136+
137+
# Test locally
138+
docker run --rm svn-binary:local --version
139+
```
140+
141+
### Running Tests
142+
143+
```bash
144+
# Install dependencies
145+
npm install
146+
147+
# Build action
148+
npm run build
149+
150+
# Run smoke tests
151+
docker build -t svn-binary:test .
152+
docker run --rm svn-binary:test --version
153+
```
154+
155+
## Contributing
156+
157+
Contributions are welcome. Please follow these guidelines:
158+
159+
1. Fork the repository
160+
2. Create a feature branch (`git checkout -b feature/improvement`)
161+
3. Commit changes with clear messages
162+
4. Submit a pull request with a description of changes
163+
164+
For bug reports and feature requests, please open an issue with detailed information.
165+
166+
## License
167+
168+
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
169+
170+
## Acknowledgments
171+
172+
This action is maintained by [Code Snippets Pro](https://github.com/codesnippetspro) and is designed to support automated deployment workflows for WordPress plugins and other SVN-based repositories.

0 commit comments

Comments
 (0)