Skip to content

Commit

Permalink
feat(env): add env DOCKER_BASE_IMAGE_TAG to set baseImageTag
Browse files Browse the repository at this point in the history
fix #386
  • Loading branch information
lgaticaq committed Aug 17, 2021
1 parent 9281340 commit 8843469
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ The plugin can be configured in the [**semantic-release** configuration file](ht

Environment variables are variables. Depends of `registries` option.

| Variable | Description |
| ----------------- | ----------------------------- |
| `DOCKER_USER` | username for docker registry. |
| `DOCKER_PASSWORD` | password for docker registry. |
| Variable | Description |
| ----------------------- | ----------------------------- |
| `DOCKER_USER` | username for docker registry. |
| `DOCKER_PASSWORD` | password for docker registry. |
| `DOCKER_BASE_IMAGE_TAG` | Name of the previously constructed docker image tag. Optional. Default `"latest"`. |

### Examples

Expand Down
2 changes: 1 addition & 1 deletion src/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = async (pluginConfig, ctx) => {
if (pluginConfig.additionalTags && pluginConfig.additionalTags.length > 0) {
tags.push(...pluginConfig.additionalTags)
}
const baseImageTag = pluginConfig.baseImageTag || 'latest'
const baseImageTag = ctx.env.DOCKER_BASE_IMAGE_TAG || pluginConfig.baseImageTag || 'latest'
for (const tag of tags) {
ctx.logger.log(
`Tagging docker image ${pluginConfig.baseImageName}:${baseImageTag} to ${pluginConfig.baseImageName}:${tag}`
Expand Down
2 changes: 1 addition & 1 deletion src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const pushImage = response => {
module.exports = async (pluginConfig, ctx) => {
try {
const docker = new Dockerode()
const baseImageTag = pluginConfig.baseImageTag || 'latest'
const baseImageTag = ctx.env.DOCKER_BASE_IMAGE_TAG || pluginConfig.baseImageTag || 'latest'
const tags = [baseImageTag, ctx.nextRelease.version]
if (pluginConfig.additionalTags && pluginConfig.additionalTags.length > 0) {
tags.push(...pluginConfig.additionalTags)
Expand Down

0 comments on commit 8843469

Please sign in to comment.