-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (90 loc) · 3.5 KB
/
dockerPublish.yml
File metadata and controls
100 lines (90 loc) · 3.5 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Publish Docker image
on:
workflow_dispatch:
push:
branches:
- workflow-test
paths:
- 'api/source/**'
- 'clients/extjs/**'
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
# Optionally: unshallow as a separate operation
-
name: Repo metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
-
name: Prepare
id: prep
run: |
git fetch --prune --unshallow
DOCKER_IMAGE=carlsmig/stig-manager-test
BRANCH=$(git symbolic-ref --short HEAD)
SHA=$(git rev-parse --short=10 HEAD)
DESCRIBE=$(git describe --tags)
TAG=$(git describe --tags --abbrev=0)
TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${TAG}"
echo ::set-output name=version::${TAG}
echo ::set-output name=tag::${TAG}
echo ::set-output name=branch::${BRANCH}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=describe::${DESCRIBE}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
# pull: true
push: true
build-args: |
COMMIT_BRANCH=${{ steps.prep.outputs.branch }}
COMMIT_SHA=${{ github.sha }}
COMMIT_TAG=${{ steps.prep.outputs.tag }}
COMMIT_DESCRIBE=${{ steps.prep.outputs.describe }}
# cache-from: type=registry,ref=myorg/myrepository:latest
# cache-to: type=inline
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ steps.prep.outputs.describe }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
-
name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: carlsmig/stig-manager-test
short-description: An API and Web client for managing STIG assessments.
readme-filepath: ./docs/DockerHub_Readme.md