Skip to content

Commit e93ab79

Browse files
committed
feat: initial release
0 parents  commit e93ab79

14 files changed

Lines changed: 2421 additions & 0 deletions

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
- package-ecosystem: npm
8+
directory: /
9+
schedule:
10+
interval: weekly

.github/workflows/autobuild.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: autobuild
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
autobuild:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
17+
- name: Install dependencies
18+
run: npm ci
19+
20+
- name: Build
21+
run: npm run build
22+
23+
- uses: nexthink-oss/ghup/actions/setup@main
24+
25+
- name: Idempotently commit updated artifacts
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}
28+
GHUP_BRANCH: ${{ github.head_ref }}
29+
GHUP_MESSAGE: "ci: autobuild #${{ github.event.pull_request.number }}"
30+
GHUP_TRAILER: '{"Build-Logs": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
31+
run: ghup content dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2025 Robin Breathe <robin@isometry.net>
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
13+
all 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
21+
THE SOFTWARE.

README.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Docker Credential Env Setup Action
2+
3+
This GitHub Action installs [`docker-credential-env`](https://github.com/isometry/docker-credential-env) and configures Docker to use it for specified registries.
4+
5+
## Features
6+
7+
- Configures Docker to use environment variables for authentication for specified registries (default ghcr.io)
8+
- Uses GitHub Actions runner tool cache for efficient caching
9+
- Cross-platform support (Linux, macOS, Windows)
10+
11+
## Usage
12+
13+
Add the following step to your GitHub Actions workflow:
14+
15+
```yaml
16+
- name: Setup docker-credential-env
17+
uses: isometry/setup-docker-credential-env@v1
18+
with:
19+
version: latest # Optional: specific version or 'latest'
20+
registries: ghcr.io docker.io quay.io # Optional: whitespace-delimited list of registries
21+
```
22+
23+
## Inputs
24+
25+
| Name | Description | Required | Default |
26+
|------|-------------|----------|---------|
27+
| `version` | Version of docker-credential-env to install (e.g., '1.3.1' or 'latest') | No | `latest` |
28+
| `registries` | Whitespace-delimited list of OCI registries to configure | No | `ghcr.io` |
29+
30+
## Outputs
31+
32+
| Name | Description |
33+
|------|-------------|
34+
| `binary-path` | Path to the installed docker-credential-env binary |
35+
| `version` | The version of docker-credential-env that was installed |
36+
37+
## Example Workflows
38+
39+
### Basic usage with GitHub Packages
40+
41+
```yaml
42+
name: Build and Push
43+
44+
on:
45+
push:
46+
branches: [ main ]
47+
48+
jobs:
49+
build:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
54+
- name: Setup docker-credential-env
55+
uses: isometry/docker-credential-env/setup@v1
56+
57+
- name: Build and push
58+
run: |
59+
docker build -t ghcr.io/myorg/myapp:latest .
60+
docker push ghcr.io/myorg/myapp:latest
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
```
64+
65+
### Multiple registries with different credentials
66+
67+
```yaml
68+
name: Push to Multiple Registries
69+
70+
on:
71+
release:
72+
types: [published]
73+
74+
jobs:
75+
push:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v3
79+
80+
- name: Setup docker-credential-env
81+
uses: isometry/docker-credential-env/setup@v1
82+
with:
83+
registries: 'ghcr.io docker.io quay.io'
84+
85+
- name: Build and push
86+
run: |
87+
docker build -t ghcr.io/myorg/myapp:${{ github.ref_name }} .
88+
docker tag ghcr.io/myorg/myapp:${{ github.ref_name }} docker.io/myorg/myapp:${{ github.ref_name }}
89+
docker tag ghcr.io/myorg/myapp:${{ github.ref_name }} quay.io/myorg/myapp:${{ github.ref_name }}
90+
91+
docker push ghcr.io/myorg/myapp:${{ github.ref_name }}
92+
docker push docker.io/myorg/myapp:${{ github.ref_name }}
93+
docker push quay.io/myorg/myapp:${{ github.ref_name }}
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For ghcr.io
96+
DOCKER_docker_io_USR: ${{ secrets.DOCKERHUB_USERNAME }}
97+
DOCKER_docker_io_PSW: ${{ secrets.DOCKERHUB_TOKEN }}
98+
DOCKER_quay_io_USR: ${{ secrets.QUAY_USERNAME }}
99+
DOCKER_quay_io_PSW: ${{ secrets.QUAY_PASSWORD }}
100+
```
101+
102+
### Using with AWS ECR
103+
104+
```yaml
105+
name: Push to AWS ECR
106+
107+
on:
108+
push:
109+
branches: [ main ]
110+
111+
jobs:
112+
build:
113+
runs-on: ubuntu-latest
114+
steps:
115+
- uses: actions/checkout@v4
116+
117+
- name: Setup docker-credential-env
118+
uses: isometry/docker-credential-env/setup@v1
119+
with:
120+
registries: '123456789012.dkr.ecr.us-east-1.amazonaws.com'
121+
122+
- name: Build and push
123+
env:
124+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
125+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
126+
run: |
127+
docker build -t 123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest .
128+
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp:latest
129+
```
130+
131+
## Development
132+
133+
This action is built using TypeScript and the [@actions/toolkit](https://github.com/actions/toolkit) libraries.
134+
135+
### Prerequisites
136+
137+
- Node.js 20+
138+
- npm
139+
140+
### Setup
141+
142+
```bash
143+
# Install dependencies
144+
npm install
145+
146+
# Build the action
147+
npm run build
148+
149+
# Run linting
150+
npm run lint
151+
152+
# Format code
153+
npm run format
154+
155+
# Run all checks and build
156+
npm run all
157+
158+
# Update dependencies
159+
npm run update-deps
160+
```
161+
162+
## How It Works
163+
164+
1. The action determines the platform and architecture of the runner
165+
2. It downloads the appropriate `docker-credential-env` binary for the platform
166+
3. The binary is stored in the GitHub Actions tool cache for reuse
167+
4. It updates `~/.docker/config.json` to use `docker-credential-env` for authentication with specified registries
168+
5. When Docker needs to authenticate with a configured registry, it will use environment variables supplied by the workflow

action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Setup docker-credential-env"
2+
description: "Install docker-credential-env and configure Docker to use it for specified registries"
3+
author: "isometry"
4+
branding:
5+
icon: "lock"
6+
color: "blue"
7+
8+
inputs:
9+
version:
10+
description: "Version of docker-credential-env to install"
11+
required: false
12+
default: latest
13+
registries:
14+
description: "Space-separated list of OCI registries to configure"
15+
required: false
16+
default: ghcr.io
17+
18+
outputs:
19+
binary-path:
20+
description: "Path to the installed docker-credential-env binary"
21+
version:
22+
description: "The version of docker-credential-env that was installed"
23+
24+
runs:
25+
using: node20
26+
main: dist/index.js

dist/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)