Skip to content

Commit 4f4f089

Browse files
committed
...
1 parent 87abe5f commit 4f4f089

File tree

4 files changed

+299
-299
lines changed

4 files changed

+299
-299
lines changed

.github/workflows/docker-publish.yml

+80-80
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,80 @@
1-
name: Docker
2-
3-
on:
4-
push:
5-
# Publish `main` as Docker `latest` image.
6-
branches:
7-
- main
8-
9-
# Publish `v1.2.3` tags as releases.
10-
tags:
11-
- v*
12-
13-
# Run tests for any PRs.
14-
pull_request:
15-
16-
env:
17-
# TODO: Change variable to your image's name.
18-
IMAGE_NAME: tools-docker-gittools
19-
ORG_NAME: dboneslabs
20-
21-
jobs:
22-
# Run tests.
23-
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
24-
test:
25-
runs-on: ubuntu-latest
26-
27-
steps:
28-
- uses: actions/checkout@v2
29-
30-
- name: Run tests
31-
run: |
32-
if [ -f docker-compose.test.yml ]; then
33-
docker-compose --file docker-compose.test.yml build
34-
docker-compose --file docker-compose.test.yml run sut
35-
else
36-
docker build . --file Dockerfile
37-
fi
38-
39-
# Push image to GitHub Packages.
40-
# See also https://docs.docker.com/docker-hub/builds/
41-
push:
42-
# Ensure test job passes before pushing image.
43-
needs: test
44-
45-
runs-on: ubuntu-latest
46-
if: github.event_name == 'push'
47-
48-
steps:
49-
- uses: actions/checkout@v2
50-
51-
- name: Build image
52-
run: docker build . --file Dockerfile --tag $IMAGE_NAME
53-
54-
- name: Login to DockerHub
55-
uses: docker/login-action@v1
56-
with:
57-
username: ${{ secrets.DOCKERHUB_USERNAME }}
58-
password: ${{ secrets.DOCKERHUB_TOKEN }}
59-
60-
- name: Push image to GitHub Container Registry
61-
run: |
62-
IMAGE_ID=$ORG_NAME/$IMAGE_NAME
63-
64-
# Change all uppercase to lowercase
65-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
66-
67-
# Strip git ref prefix from version
68-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
69-
70-
# Strip "v" prefix from tag name
71-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
72-
73-
# Use Docker `latest` tag convention
74-
[ "$VERSION" == "main" ] && VERSION=latest
75-
76-
echo IMAGE_ID=$IMAGE_ID
77-
echo VERSION=$VERSION
78-
79-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
80-
docker push $IMAGE_ID:$VERSION
1+
name: Docker
2+
3+
on:
4+
push:
5+
# Publish `main` as Docker `latest` image.
6+
branches:
7+
- main
8+
9+
# Publish `v1.2.3` tags as releases.
10+
tags:
11+
- v*
12+
13+
# Run tests for any PRs.
14+
pull_request:
15+
16+
env:
17+
# TODO: Change variable to your image's name.
18+
IMAGE_NAME: tools-docker-gittools
19+
ORG_NAME: dboneslabs
20+
21+
jobs:
22+
# Run tests.
23+
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
24+
test:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Run tests
31+
run: |
32+
if [ -f docker-compose.test.yml ]; then
33+
docker-compose --file docker-compose.test.yml build
34+
docker-compose --file docker-compose.test.yml run sut
35+
else
36+
docker build . --file Dockerfile
37+
fi
38+
39+
# Push image to GitHub Packages.
40+
# See also https://docs.docker.com/docker-hub/builds/
41+
push:
42+
# Ensure test job passes before pushing image.
43+
needs: test
44+
45+
runs-on: ubuntu-latest
46+
if: github.event_name == 'push'
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Build image
52+
run: docker build . --file Dockerfile --tag $IMAGE_NAME
53+
54+
- name: Login to DockerHub
55+
uses: docker/login-action@v1
56+
with:
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_TOKEN }}
59+
60+
- name: Push image to GitHub Container Registry
61+
run: |
62+
IMAGE_ID=$ORG_NAME/$IMAGE_NAME
63+
64+
# Change all uppercase to lowercase
65+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
66+
67+
# Strip git ref prefix from version
68+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
69+
70+
# Strip "v" prefix from tag name
71+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
72+
73+
# Use Docker `latest` tag convention
74+
[ "$VERSION" == "main" ] && VERSION=latest
75+
76+
echo IMAGE_ID=$IMAGE_ID
77+
echo VERSION=$VERSION
78+
79+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
80+
docker push $IMAGE_ID:$VERSION

Dockerfile

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:3.1
2-
3-
LABEL repository="https://github.com/dbones-labs/tools-docker-gittools"
4-
LABEL maintainer="dbones labs"
5-
6-
RUN apt-get update && apt-get install -y jq && apt-get install -y git-all
7-
RUN dotnet tool install -g GitVersion.Tool
8-
RUN dotnet tool install -g GitReleaseManager.Tool
9-
RUN dotnet tool install -g dotnet-setversion
10-
11-
ENV PATH /root/.dotnet/tools:$PATH
12-
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
1+
FROM mcr.microsoft.com/dotnet/sdk:3.1
2+
3+
LABEL repository="https://github.com/dbones-labs/tools-docker-gittools"
4+
LABEL maintainer="dbones labs"
5+
6+
RUN apt-get update && apt-get install -y jq && apt-get install -y git-all
7+
RUN dotnet tool install -g GitVersion.Tool
8+
RUN dotnet tool install -g GitReleaseManager.Tool
9+
RUN dotnet tool install -g dotnet-setversion
10+
11+
ENV PATH /root/.dotnet/tools:$PATH
12+
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

0 commit comments

Comments
 (0)