Debian Codegraph @

.github/workflows/publish-docker.yml

raw symbols SCIP
1 name: Publish Docker
2 run-name: "Publish Docker (gitlint_version=${{ inputs.gitlint_version }})"
3
4 on:
5 workflow_call:
6 inputs:
7 gitlint_version:
8 description: "Gitlint version to build docker image for"
9 required: true
10 type: string
11 docker_image_tag:
12 description: "Docker image tag"
13 required: true
14 type: string
15 push_to_dockerhub:
16 description: "Push to dockerhub.com"
17 required: false
18 type: boolean
19 default: false
20 workflow_dispatch:
21 inputs:
22 gitlint_version:
23 description: "Gitlint version to build docker image for"
24 type: string
25 docker_image_tag:
26 description: "Docker image tag"
27 required: true
28 type: choice
29 options:
30 - "latest_dev"
31 - "latest"
32 - "Use $gitlint_version"
33 default: "Use $gitlint_version"
34 push_to_dockerhub:
35 description: "Push to dockerhub.com"
36 required: false
37 type: boolean
38 default: false
39
40 jobs:
41 publish_docker:
42 runs-on: "ubuntu-latest"
43 steps:
44 - name: Determine docker tag
45 id: set_tag
46 run: |
47 if [[ "${{ inputs.docker_image_tag }}" == "Use $gitlint_version" ]]; then
48 echo "docker_image_tag=${{ inputs.gitlint_version }}" >> $GITHUB_OUTPUT
49 else
50 echo "docker_image_tag=${{ inputs.docker_image_tag }}" >> $GITHUB_OUTPUT
51 fi
52
53 - name: Login to Docker Hub
54 uses: docker/login-action@v2
55 with:
56 username: jorisroovers
57 password: ${{ secrets.DOCKERHUB_TOKEN }}
58
59 - name: Build docker image
60 uses: docker/build-push-action@v4
61 with:
62 build-args: GITLINT_VERSION=${{ inputs.gitlint_version }}
63 tags: jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }}
64
65 - name: Test docker image
66 run: |
67 gitlint_version=$(docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} --version)
68 [ "$gitlint_version" == "gitlint, version ${{ inputs.gitlint_version }}" ]
69
70
71 # This won't actually rebuild the docker image, but just push the previously built and cached image
72 - name: Push docker image
73 uses: docker/build-push-action@v4
74 with:
75 push: ${{ inputs.push_to_dockerhub }}
76 build-args: GITLINT_VERSION=${{ inputs.gitlint_version }}
77 tags: jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }}
78 if: inputs.push_to_dockerhub
79