-
Notifications
You must be signed in to change notification settings - Fork 3
46 lines (40 loc) · 1.32 KB
/
docker-image.yaml
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
name: Docker Image CI
on:
push:
tags:
- '*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch the tags
run: |
# fetch the history (including tags) from within a shallow clone
git fetch --prune --unshallow
- name: Build the Docker image
run: |
# Get tag and remove `v', if exists
tag=`git describe --tags`;
tag=${tag//v/};
# to lowercase
image_name="${{ env.IMAGE_NAME }}"
image_name="`echo "$image_name" | sed -e 's/\(.*\)/\L\1/'`"
docker build -f ./docker/Dockerfile --tag ${{ env.REGISTRY }}/$image_name:$tag .;
echo "image_name=$image_name" >> $GITHUB_ENV;
echo "tag=$tag" >> $GITHUB_ENV;
- name: Test Docker Image
run: ./docker/tests/runImageTests.sh ${{ env.REGISTRY }}/$image_name:$tag
- name: Push docker image to registry
run: docker push ${{ env.REGISTRY }}/$image_name:$tag