Skip to content

Commit 3e37a48

Browse files
committed
Add support for alias tags for canary (if pull request), pre-releases (with mapping to specific aliases per branch), and latest. All docker alias tags are also pushed to git
1 parent bbaf45b commit 3e37a48

File tree

3 files changed

+452
-31
lines changed

3 files changed

+452
-31
lines changed

plugins/docker/README.md

+48-8
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,73 @@ yarn add -D @auto-it/docker
1818

1919
## Usage
2020

21-
You must first must build the desired image to publish.
21+
**IMPORTANT:** You must first must build the desired image to publish.
2222

23-
These environment variables tell `auto` what to publish.
23+
The following options are available for this plugin:
2424

25-
- IMAGE - The image ID, digest, or tag of the locally available image to tag and publish. This is required unless you want to statically tag the local image, in which case you can provide it as an option.
25+
|option|required|default|environment variable|description|
26+
|-|-|-|-|-|
27+
| `image` | X | | `IMAGE` | The image ID, digest, or tag of the locally available image to tag and publish (must be built before this plugin is run) |
28+
| `registry` | X | | `REGISTRY` | Docker registry to publish to |
29+
| `tagLatest` | | `false` | `TAG_LATEST` | Tag latest release with `latest` tag |
30+
| `tagPullRequestAliases` | | `false` | `TAG_PULL_REQUEST_ALIASES` | Tag pull requests with `pr-<number>` tag |
31+
| `tagPrereleaseAliases` | | `false` | `TAG_PRERELEASE_ALIASES` | Tag prerelease branches
32+
| `prereleaseAliasMappings` | | `{}` | | Tag prerelease branches with different names (e.g. `{"develop": "next"}`) |
2633

34+
### Example 1: Tag releases only
2735
```json
2836
{
2937
"plugins": [
30-
["docker", { "registry": "ghcr.io/my/app" }]
38+
["docker", { "registry": "ghcr.io/my/app", "image": "someLocalImage:myLocalTag" }]
3139
// other plugins
3240
]
3341
}
3442
```
3543

36-
If you'd like to tag releases with `latest` too, you can specify the `tagLatest` option:
44+
This will publish releases from the local docker image `someLocalImage:myLocalTag` to: - `ghcr.io/my/app:<version>`
3745

46+
### Example 2: Tag latest releases
3847
```json
3948
{
40-
"plugins": [["docker", { "registry": "ghcr.io/my/app", "tagLatest": true }]]
49+
"plugins": [
50+
["docker", { "registry": "ghcr.io/my/app", "image": "someLocalImage:myLocalTag", "tagLatest": true }]
51+
// other plugins
52+
]
4153
}
4254
```
4355

44-
If you're tagging the locally built image in a static manner, you can also pass `image` instead of `IMAGE` as an environment variable.
56+
This will publish releases from the local docker image `someLocalImage:myLocalTag` to: - `ghcr.io/my/app:<version>`
57+
- `ghcr.io/my/app:latest`
4558

59+
### Example 3: Tag Prereleases (with Custom Tags)
4660
```json
4761
{
48-
"plugins": [["docker", { "registry": "ghcr.io/my/app", "image": "myapp" }]]
62+
"prereleaseBranches": ["develop", "someOtherPrereleaseBranch"],
63+
"plugins": [
64+
["docker", { "registry": "ghcr.io/my/app", "image": "someLocalImage:myLocalTag", "tagPrereleases": true, "prereleaseTagMapping": { "develop": "next" } }]
65+
// other plugins
66+
]
4967
}
5068
```
69+
70+
For pushes to `develop` branch this will create the following tags:
71+
- `ghcr.io/my/app:<prereleaseVersion>`
72+
- `ghcr.io/my/app:next`
73+
74+
For pushes to `someOtherReleaseBranch` this will create the following tags:
75+
- `ghcr.io/my/app:<prereleaseVersion>`
76+
- `ghcr.io/my/app:someOtherReleaseBranch`
77+
78+
### Example 4: Tag Pull Requests
79+
```json
80+
{
81+
"plugins": [
82+
["docker", { "registry": "ghcr.io/my/app", "image": "someLocalImage:myLocalTag", "tagPullRequests": true }]
83+
// other plugins
84+
]
85+
}
86+
```
87+
88+
If this is run against a pull request the following tags will be created against `someLocalImage:myLocalTag`:
89+
- `ghcr.io/my/app:<canaryVersion>`
90+
- `ghcr.io/my/app:pr-<prNumber>`

0 commit comments

Comments
 (0)