-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
78 lines (72 loc) · 2.8 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# composite action https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-composite-run-steps-action
name: 'Build Docker Image'
description: 'Builds and Pushes Docker Images with some Keptn Internals'
inputs:
IMAGE_NAME:
description: Image Name, e.g., keptn/some-service or keptn-contrib/some-service
required: true
DOCKER_FOLDER:
description: In case you are trying to build from a subfolder, set this to the subfolder (must end in a trailing slash)
default: './'
VERSION:
description: Semantic version used as the tag of the docker image
required: true
DATETIME:
description: Optional datetime for the tag of the docker image (will be set automatically if left empty)
default: unset
FILE:
description: Optional name of the Dockerfile
default: 'Dockerfile'
runs:
using: composite
steps:
- shell: bash
id: check_datetime
env:
DATETIME: ${{ inputs.DATETIME }}
run: |
if [[ "$DATETIME" == "unset" ]] || [[ "$DATETIME" == "" ]]; then
# generate datetime
echo Generating datetime using date command
echo "::set-output name=DATETIME::$(date +'%Y%m%d')$(date +'%H%M')"
else
# use provided datetime
echo Using provided datetime $DATETIME
echo "::set-output name=DATETIME::${DATETIME}"
fi
- shell: bash
id: check_docker_folder
env:
DOCKER_FOLDER: ${{ inputs.DOCKER_FOLDER }}
run: |
# ensure trailing slash in folder
if [[ "${DOCKER_FOLDER}" != */ ]]; then
echo "::error Please ensure that FOLDER has a trailing slash, e.g., ./ or api/"
exit 1
fi
- shell: bash
id: prepare_manifest
name: Prepare Build Manifest
env:
DOCKER_FOLDER: ${{ inputs.DOCKER_FOLDER }}
DATETIME: ${{ steps.check_datetime.outputs.DATETIME }}
run: |
${{ github.action_path }}/docker/writeManifest.sh ${{ github.action_path }}/docker/MANIFEST
cat ${{ github.action_path }}/docker/MANIFEST
# copy manifest
cp ${{ github.action_path }}/docker/MANIFEST ./${DOCKER_FOLDER}MANIFEST
if [[ $? -ne 0 ]]; then
echo "::error Could not find MANIFEST"
exit 1
fi
# copy entrypoint script
cp ${{ github.action_path }}/docker/entrypoint.sh ./${DOCKER_FOLDER}entrypoint.sh
- shell: bash
id: composite-action-build-docker-image
env:
IMAGE_NAME: ${{ inputs.IMAGE_NAME }}
DOCKER_FOLDER: ${{ inputs.DOCKER_FOLDER }}
VERSION: ${{ inputs.VERSION }}
DATETIME: ${{ steps.check_datetime.outputs.DATETIME }}
FILE: ${{ inputs.FILE }}
run: ${{ github.action_path }}/build_docker_image.sh "${IMAGE_NAME}" "${DOCKER_FOLDER}" "${VERSION}" "${DATETIME}" "${FILE}"