Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit d5d966c

Browse files
authored
Merge pull request #11 from 123FLO321/patch-1
Thank you for the contribution @123FLO321 * Introduce useful default tag name for MRs * Add imageTagPrefix and imageTagSuffix "You can have *GitHub Docker* decide the tag of the image, and prepend or append something you like to it."
2 parents 429a7f3 + e5edf73 commit d5d966c

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ Build and publish your repository as a Docker image and push it to GitHub Packag
2828

2929
*Optional*. The desired tag for the image. Defaults to current branch or release version number.
3030

31+
### `imageTagPrefix`
32+
33+
*Optional*. Added to the beginning of the tag.
34+
35+
### `imageTagSuffix`
36+
37+
*Optional*. Added to the end of the tag.
38+
3139
### `buildArguments`
3240

3341
*Optional*. Any additional build arguments to use when building the image.

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ inputs:
2020
imageTag:
2121
description: "The desired tag for the image. Defaults to current branch or release version number."
2222
required: false
23+
imageTagPrefix:
24+
description: "Added to the beginning of the tag."
25+
required: false
26+
imageTagSuffix:
27+
description: "Added to the end of the tag."
28+
required: false
2329
buildArguments:
2430
description: "The build arguments for image."
2531
required: false

dist/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,18 @@ async function run() {
693693
let imageTag = core.getInput('imageTag', { required: false });
694694
const ref = process.env['GITHUB_REF'];
695695
const refArray = ref.split('/');
696-
if (!imageTag) imageTag = refArray[refArray.length - 1];
696+
if (!imageTag) {
697+
const refLast = refArray[refArray.length - 1];
698+
if (refLast === "merge" && refArray.length >= 2) {
699+
imageTag = "mr" + refArray[refArray.length - 2];
700+
} else {
701+
imageTag = refLast;
702+
}
703+
}
704+
let imageTagPrefix = core.getInput('imageTagPrefix', { required: false });
705+
if (imageTagPrefix) imageName = imageTagPrefix + imageName;
706+
let imageTagSuffix = core.getInput('imageTagSuffix', { required: false });
707+
if (imageTagSuffix) imageName = imageName + imageTagSuffix;
697708

698709
// Set some variables.
699710
const imageURL = `docker.pkg.github.com/${repository}/${imageName}:${imageTag}`
@@ -1073,4 +1084,4 @@ exports.exec = exec;
10731084

10741085
/***/ })
10751086

1076-
/******/ });
1087+
/******/ });

0 commit comments

Comments
 (0)