You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for multiple Docker registries including ghcr.io
This commit adds comprehensive multi-registry support to the Kamal
Accessories Updater, starting with GitHub Container Registry (ghcr.io).
Key Changes:
- Added parse_image_name() function to parse registry prefix from image names
(e.g., ghcr.io/org/image, docker.io/library/redis)
- Added detect_registry_type() function to identify registry type
- Implemented GHCR-specific functions:
* get_latest_version_ghcr() - Fetches tags from GHCR with token auth
* get_image_sha256_ghcr() - Retrieves SHA256 digests from GHCR
- Refactored Docker Hub functions into registry-specific implementations:
* get_latest_version_dockerhub()
* get_image_sha256_dockerhub()
- Updated main dispatcher functions to route to appropriate registry handlers
- Enhanced caching to support multiple registries with separate cache keys
- Added GHCR_TOKEN environment variable support for authentication
Registry Support:
- Docker Hub (docker.io) - Full support, no auth required for public images
- GitHub Container Registry (ghcr.io) - Full support with token authentication
- Google Container Registry (gcr.io) - Detection ready
- Quay.io - Detection ready
- Generic OCI registries - Basic detection
Documentation:
- Updated README with multi-registry support information
- Added "Supported Registries" section with examples
- Documented GHCR authentication requirements
- Added configuration examples for different registries
- Updated "How It Works" section to reflect registry detection
The implementation maintains backward compatibility with existing Docker Hub
configurations while enabling users to specify registry prefixes for images
from other registries.
A GitHub Action that automatically checks for and updates [Kamal](https://kamal-deploy.org/) accessories to their latest versions from Docker Hub.
6
+
A GitHub Action that automatically checks for and updates [Kamal](https://kamal-deploy.org/) accessories to their latest versions from Docker Hub, GitHub Container Registry (GHCR), and other OCI registries.
7
7
8
8
## Features
9
9
10
-
- 🔍 **Automatic Version Detection** - Scans your Kamal deployment configurations for accessories and checks Docker Hub for latest versions
10
+
- 🔍 **Automatic Version Detection** - Scans your Kamal deployment configurations for accessories and checks registries for latest versions
11
+
- 🌐 **Multi-Registry Support** - Works with Docker Hub, GitHub Container Registry (ghcr.io), and other OCI-compliant registries
11
12
- 📦 **Semantic Versioning** - Intelligently compares semantic versions to ensure only newer versions are applied
12
13
- 🔒 **SHA256 Support** - Automatically fetches and includes SHA256 digests for enhanced security
13
14
- 📝 **Pull Request Creation** - Optionally creates pull requests with detailed update information
@@ -139,11 +140,12 @@ Check for updates and create a PR:
139
140
140
141
1. **Scans Configuration Files** - Finds all `deploy*.yml` files in your config directory
141
142
2. **Extracts Accessories** - Parses YAML to identify accessories and their current versions
142
-
3. **Checks Docker Hub** - Queries Docker Hub API for latest semantic versions
143
-
4. **Compares Versions** - Intelligently compares versions to determine if updates are available
144
-
5. **Fetches Digests** - Retrieves SHA256 digests for the latest versions
145
-
6. **Updates Files** - Modifies your configuration files with new versions and digests
146
-
7. **Creates PR** - Optionally creates a pull request with the changes
143
+
3. **Detects Registry** - Automatically detects the registry (Docker Hub, GHCR, etc.) from the image name
144
+
4. **Queries Registry API** - Fetches latest semantic versions from the appropriate registry
145
+
5. **Compares Versions** - Intelligently compares versions to determine if updates are available
146
+
6. **Fetches Digests** - Retrieves SHA256 digests for the latest versions
147
+
7. **Updates Files** - Modifies your configuration files with new versions and digests
148
+
8. **Creates PR** - Optionally creates a pull request with the changes
147
149
148
150
## Supported Accessories
149
151
@@ -156,37 +158,112 @@ This action works with any Docker image used as a Kamal accessory. Common exampl
156
158
- BusyBox (`busybox`)
157
159
- Any custom Docker image on Docker Hub
158
160
161
+
## Supported Registries
162
+
163
+
The action supports multiple container registries:
164
+
165
+
### Docker Hub (docker.io)
166
+
167
+
**Default registry** - No authentication required for public images.
168
+
169
+
```yaml
170
+
accessories:
171
+
redis:
172
+
image: redis:7.0.0 # Official image (implicit docker.io)
**Requires authentication** for most operations. Set the `GHCR_TOKEN` environment variable with a GitHub Personal Access Token (PAT) or use the automatic `GITHUB_TOKEN`.
184
+
185
+
```yaml
186
+
accessories:
187
+
myapp:
188
+
image: ghcr.io/myorg/myapp:1.0.0
189
+
190
+
public:
191
+
image: ghcr.io/owner/public-image:2.0.0
192
+
```
193
+
194
+
**GitHub Action Configuration for GHCR:**
195
+
196
+
```yaml
197
+
- name: Update accessories
198
+
uses: robfrank/kamal-accessories-updater@v1
199
+
with:
200
+
config-dir: config
201
+
env:
202
+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use GitHub token for GHCR access
203
+
```
204
+
205
+
**For private GHCR images**, create a GitHub PAT with `read:packages` scope:
206
+
207
+
```yaml
208
+
env:
209
+
GHCR_TOKEN: ${{ secrets.GHCR_PAT }} # Use custom PAT for private images
210
+
```
211
+
212
+
### Other Registries
213
+
214
+
The action includes detection for:
215
+
- **Google Container Registry** (gcr.io)
216
+
- **Quay.io** (quay.io)
217
+
- **Generic OCI registries** (basic support)
218
+
219
+
Support for additional registries is being actively developed. Open an issue if you need support for a specific registry.
220
+
159
221
## Configuration File Format
160
222
161
223
Your Kamal configuration files should follow the standard format:
162
224
163
225
```yaml
164
226
accessories:
227
+
# Docker Hub - official image (default registry)
165
228
redis:
166
229
image: redis:7.0.0
167
230
host: 192.168.0.1
168
231
# ... other configuration
169
232
233
+
# Docker Hub - with SHA256 digest
170
234
postgres:
171
235
image: postgres:15.0@sha256:abc123...
172
236
host: 192.168.0.1
173
237
# ... other configuration
238
+
239
+
# GitHub Container Registry
240
+
myapp:
241
+
image: ghcr.io/myorg/myapp:1.2.3@sha256:def456...
242
+
host: 192.168.0.1
243
+
# ... other configuration
244
+
245
+
# Docker Hub - organization image
246
+
custom:
247
+
image: mycompany/myservice:2.0.0
248
+
host: 192.168.0.1
249
+
# ... other configuration
174
250
```
175
251
176
252
The action will:
253
+
- Automatically detect the registry from the image name
177
254
- Preserve your existing configuration structure
178
255
- Update only the image version
179
256
- Add or update SHA256 digests
180
257
- Keep all other settings intact
181
258
182
259
## Caching
183
260
184
-
The action caches Docker Hub API responses for 1 hour to:
261
+
The action caches registry API responses for 1 hour to:
185
262
- Reduce API calls
186
263
- Improve performance
187
264
- Avoid rate limiting
188
265
189
-
Cache is stored in `/tmp/docker-registry-cache` and automatically cleaned up.
266
+
Cache is stored in `/tmp/docker-registry-cache` and automatically cleaned up. Each registry is cached separately to ensure accuracy.
190
267
191
268
## Testing
192
269
@@ -256,6 +333,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
0 commit comments