Skip to content
This repository was archived by the owner on Dec 9, 2022. It is now read-only.

Commit 135f213

Browse files
author
Patrick Poetz
committed
Introduced CI for action testing. Added feature to use Git tags as
Docker tags. introduce CI simplified identification, introduced ci and fixed metadata non interactive docker login assuming the right context simplification is difficult simplification is difficult 2 do it the complicated way test image_tag function publish 2nd version echoing tags pointing to current commit build tag string fixed a few typos fixed another typo create additional tags based on GIT Tags pointing to the current commit added feature which adds GIT tags pointing to the current commit as docker tags
1 parent 4385a90 commit 135f213

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

.github/docker/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine:3.10.3
2+
3+
ENTRYPOINT ["echo", "'hello world'"]

.github/workflows/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Test Docker Image Creation
2+
3+
on: [push]
4+
5+
jobs:
6+
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v1
12+
with:
13+
fetch-depth: 1
14+
- name: Build and Publish Docker image
15+
uses: saubermacherag/gpr-docker-publish@master
16+
with:
17+
USERNAME: x-access-token
18+
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
19+
IMAGE_NAME: 'gpr-docker-publish-test'
20+
IMAGE_TAG: 'v0.0'
21+
DOCKERFILE_PATH: '.github/docker/Dockerfile'
22+
BUILD_CONTEXT: './'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
.idea

action.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@ inputs:
1010
require: true
1111
image_name:
1212
description: name of the image. Example - myContainer
13-
require: true
13+
required: true
1414
build_context:
1515
description: the path in your repo that will serve as the build context
16-
require: true
16+
required: true
1717
default: './'
1818
dockerfile_path:
1919
description: the full path (including the filename) to the dockerfile that you want to build
20-
require: true
20+
required: true
2121
default: ./Dockerfile
2222
cache:
2323
description: attempt to use last image as the cache
24-
require: false
24+
required: false
2525
default: false
26+
image_tag:
27+
description: Optional input to set a tag name instead of a hash.
28+
required: false
2629
outputs:
2730
IMAGE_SHA_NAME:
2831
description: name of the Docker Image including the tag

entrypoint.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ echo ${INPUT_PASSWORD} | docker login -u ${INPUT_USERNAME} --password-stdin dock
4747
BASE_NAME="docker.pkg.github.com/${GITHUB_REPOSITORY}/${INPUT_IMAGE_NAME}"
4848
SHA_NAME="${BASE_NAME}:${IMAGE_TAG}"
4949

50+
# Build additional tags based on the GIT Tags pointing to the current commit
51+
ADDITIONAL_TAGS=
52+
for git_tag in $(git tag -l --points-at HEAD)
53+
do
54+
echo "Processing ${git_tag}"
55+
ADDITIONAL_TAGS="${ADDITIONAL_TAGS} -t ${BASE_NAME}:${git_tag}"
56+
done
57+
echo "following additional tags will be created: ${ADDITIONAL_TAGS}"
58+
5059
# Add Arguments For Caching
5160
BUILDPARAMS=""
5261
if [ "${INPUT_CACHE}" == "true" ]; then
@@ -58,7 +67,7 @@ if [ "${INPUT_CACHE}" == "true" ]; then
5867
fi
5968

6069
# Build The Container
61-
docker build $BUILDPARAMS -t ${SHA_NAME} -t ${BASE_NAME} -f ${INPUT_DOCKERFILE_PATH} ${INPUT_BUILD_CONTEXT}
70+
docker build $BUILDPARAMS -t ${SHA_NAME} -t ${BASE_NAME}${ADDITIONAL_TAGS} -f ${INPUT_DOCKERFILE_PATH} ${INPUT_BUILD_CONTEXT}
6271

6372
# Push two versions, with and without the SHA
6473
docker push ${BASE_NAME}

0 commit comments

Comments
 (0)