Skip to content

Commit 88df7fe

Browse files
authored
Merge pull request #3 from voxpupuli/make_it_work
feat: add container ci, build and docu
2 parents 0f4f3b9 + d86c005 commit 88df7fe

File tree

7 files changed

+287
-58
lines changed

7 files changed

+287
-58
lines changed

.commitlintrc.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# The rules below have been manually copied from @commitlint/config-conventional
3+
# and match the v1.0.0 specification:
4+
# https://www.conventionalcommits.org/en/v1.0.0/#specification
5+
#
6+
# You can remove them and uncomment the config below when the following issue is
7+
# fixed: https://github.com/conventional-changelog/commitlint/issues/613
8+
#
9+
# extends:
10+
# - '@commitlint/config-conventional'
11+
rules:
12+
body-leading-blank: [1, always]
13+
body-max-line-length: [2, always, 100]
14+
footer-leading-blank: [1, always]
15+
footer-max-line-length: [2, always, 100]
16+
header-max-length: [2, always, 100]
17+
subject-case:
18+
- 2
19+
- never
20+
- [sentence-case, start-case, pascal-case, upper-case]
21+
subject-empty: [2, never]
22+
subject-full-stop: [2, never, "."]
23+
type-case: [2, always, lower-case]
24+
type-empty: [2, never]
25+
type-enum:
26+
- 2
27+
- always
28+
- [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]

.github/workflows/build_container.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: Build and publish a 🛢️ container
3+
4+
on:
5+
push:
6+
branches:
7+
- 'main'
8+
tags:
9+
- '*'
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-and-push-container:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- name: Source checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Get commitlint version
23+
id: get_version
24+
run: echo "cl_version="$(jq -r '.dependencies."@commitlint/cli"' package.json | sed 's/\^//') >> $GITHUB_OUTPUT
25+
26+
# Parse ref_name and if it is main, change it to latest
27+
- name: Set tag
28+
id: set_tag
29+
run: echo "tag=$(echo ${{ github.ref_name }} | sed 's/^main$/latest/')" >> $GITHUB_OUTPUT
30+
31+
- name: Build Vox Pupuli commitlint container
32+
uses: voxpupuli/gha-build-and-publish-a-container@v2
33+
with:
34+
registry_password: ${{ secrets.GITHUB_TOKEN }}
35+
build_arch: linux/amd64,linux/arm64
36+
docker_username: voxpupulibot
37+
docker_password: ${{ secrets.DOCKERHUB_BOT_PASSWORD }}
38+
tags: |
39+
ghcr.io/voxpupuli/commitlint:${{ steps.get_version.outputs.cl_version }}-${{ steps.set_tag.outputs.tag }}
40+
ghcr.io/voxpupuli/commitlint:latest
41+
docker.io/voxpupuli/commitlint:${{ steps.get_version.outputs.cl_version }}-${{ steps.set_tag.outputs.tag }}
42+
docker.io/voxpupuli/commitlint:latest
43+
44+
- name: Update Docker Hub Description
45+
uses: peter-evans/dockerhub-description@v4
46+
with:
47+
username: voxpupulibot
48+
password: ${{ secrets.DOCKERHUB_BOT_PASSWORD }}
49+
repository: voxpupuli/commitlint

.github/workflows/ci.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: CI🚦
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
general_ci:
12+
uses: voxpupuli/crafty/.github/workflows/general_ci.yaml@main
13+
with:
14+
shellcheck_scan_dir: '.'
15+
16+
build_test_container:
17+
name: 'Build test container'
18+
runs-on: ubuntu-latest
19+
permissions:
20+
actions: read
21+
contents: read
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Build image
27+
uses: docker/build-push-action@v6
28+
with:
29+
tags: 'ci/test:${{ github.event.number }}'
30+
push: false
31+
32+
tests:
33+
needs:
34+
- build_test_container
35+
runs-on: ubuntu-latest
36+
name: Test suite
37+
steps:
38+
- run: echo Test suite completed
39+
40+
dependabot:
41+
permissions:
42+
contents: write
43+
name: 'Dependabot auto-merge'
44+
needs:
45+
- tests
46+
runs-on: ubuntu-latest
47+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
48+
steps:
49+
- name: Dependabot metadata
50+
id: metadata
51+
uses: dependabot/fetch-metadata@v2.2.0
52+
with:
53+
github-token: '${{ secrets.GITHUB_TOKEN }}'
54+
55+
- name: Enable auto-merge for Dependabot PRs
56+
run: gh pr merge --auto --merge "$PR_URL"
57+
env:
58+
PR_URL: ${{github.event.pull_request.html_url}}
59+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Security Scanning 🕵️
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build_test_container:
14+
name: 'Build test container'
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Build local container
25+
uses: docker/build-push-action@v6
26+
with:
27+
tags: 'ci/test:latest'
28+
push: false
29+
30+
- name: Scan image with Anchore Grype
31+
uses: anchore/scan-action@v5
32+
id: scan
33+
with:
34+
image: 'ci/test:latest'
35+
fail-build: false
36+
37+
- name: Inspect action SARIF report
38+
run: jq . ${{ steps.scan.outputs.sarif }}
39+
40+
- name: Upload Anchore scan SARIF report
41+
uses: github/codeql-action/upload-sarif@v3
42+
with:
43+
sarif_file: ${{ steps.scan.outputs.sarif }}

Dockerfile

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
FROM node:23.1.0-alpine3.20 AS build
2-
3-
WORKDIR /npm
4-
COPY package.json /npm
5-
6-
RUN npm install
7-
8-
###############################################################################
9-
10-
FROM node:23.1.0-alpine3.20 AS final
11-
12-
LABEL org.label-schema.maintainer="Voxpupuli Team <voxpupuli@groups.io>" \
13-
org.label-schema.vendor="Voxpupuli" \
14-
org.label-schema.url="https://github.com/voxpupuli/container-commitlint" \
15-
org.label-schema.name="Vox Pupuli Container for commitlint" \
16-
org.label-schema.license="AGPL-3.0-or-later" \
17-
org.label-schema.vcs-url="https://github.com/voxpupuli/container-commitlint" \
18-
org.label-schema.schema-version="1.0" \
19-
org.label-schema.dockerfile="/Dockerfile"
20-
21-
COPY Dockerfile /
22-
COPY docker-entrypoint.sh /
23-
COPY docker-entrypoint.d /docker-entrypoint.d
24-
COPY --from=build /npm /npm
25-
26-
RUN apk update && apk upgrade \
27-
&& apk add --no-cache --update bash git \
28-
&& chmod +x /docker-entrypoint.sh
29-
# && chmod +x /docker-entrypoint.d/*.sh
30-
31-
# fix ENOGITREPO Not running from a git repository.
32-
RUN git config --global --add safe.directory '*'
33-
34-
WORKDIR /data
35-
36-
ENV PATH="$PATH:/npm/node_modules/.bin"
37-
ENV NODE_OPTIONS="--use-openssl-ca"
38-
39-
ENTRYPOINT [ "/docker-entrypoint.sh" ]
1+
FROM node:23.1.0-alpine3.20 AS build
2+
3+
WORKDIR /npm
4+
COPY package.json /npm
5+
6+
RUN npm install
7+
8+
###############################################################################
9+
10+
FROM node:23.1.0-alpine3.20 AS final
11+
12+
LABEL org.label-schema.maintainer="Voxpupuli Team <voxpupuli@groups.io>" \
13+
org.label-schema.vendor="Voxpupuli" \
14+
org.label-schema.url="https://github.com/voxpupuli/container-commitlint" \
15+
org.label-schema.name="Vox Pupuli Container for commitlint" \
16+
org.label-schema.license="AGPL-3.0-or-later" \
17+
org.label-schema.vcs-url="https://github.com/voxpupuli/container-commitlint" \
18+
org.label-schema.schema-version="1.0" \
19+
org.label-schema.dockerfile="/Dockerfile"
20+
21+
COPY Dockerfile /
22+
COPY docker-entrypoint.sh /
23+
COPY docker-entrypoint.d /docker-entrypoint.d
24+
COPY --from=build /npm /npm
25+
26+
RUN apk update && apk upgrade \
27+
&& apk add --no-cache --update bash git \
28+
&& chmod +x /docker-entrypoint.sh \
29+
# fix ENOGITREPO Not running from a git repository.
30+
&& git config --global --add safe.directory '*'
31+
# && chmod +x /docker-entrypoint.d/*.sh
32+
33+
WORKDIR /data
34+
35+
ENV PATH="$PATH:/npm/node_modules/.bin"
36+
ENV NODE_OPTIONS="--use-openssl-ca"
37+
38+
ENTRYPOINT [ "/docker-entrypoint.sh" ]
39+
CMD [ "--last" ]

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,70 @@
11
# Vox Pupuli Commitlint Container
2+
3+
[![CI](https://github.com/voxpupuli/container-commitlint/actions/workflows/ci.yaml/badge.svg)](https://github.com/voxpupuli/container-commitlint/actions/workflows/ci.yaml)
4+
[![License](https://img.shields.io/github/license/voxpupuli/container-commitlint.svg)](https://github.com/voxpupuli/container-commitlint/blob/main/LICENSE)
5+
[![Sponsored by betadots GmbH](https://img.shields.io/badge/Sponsored%20by-betadots%20GmbH-blue.svg)](https://www.betadots.de)
6+
7+
This container can be used to lint commits.
8+
It encapsulates [commitlint](https://github.com/conventional-changelog/commitlint) and all necessary plugins.
9+
See [package.json](package.json) for details. This is a npm application running in an alpine container.
10+
11+
## Usage
12+
13+
### Lint last commit only
14+
15+
```shell
16+
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest
17+
# or (but thats the default)
18+
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest --last
19+
```
20+
21+
### Lint all commits from a branch
22+
23+
```shell
24+
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest \
25+
--from $(git merge-base $(git symbolic-ref refs/remotes/origin/HEAD --short) HEAD) \
26+
--to HEAD
27+
```
28+
29+
### More options
30+
31+
For more options see:
32+
33+
```shell
34+
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest --help
35+
```
36+
37+
### Example commitlint config
38+
39+
See [.commitlint.yaml](.commitlintrc.yaml)
40+
41+
```yaml
42+
---
43+
# The rules below have been manually copied from @commitlint/config-conventional
44+
# and match the v1.0.0 specification:
45+
# https://www.conventionalcommits.org/en/v1.0.0/#specification
46+
#
47+
# You can remove them and uncomment the config below when the following issue is
48+
# fixed: https://github.com/conventional-changelog/commitlint/issues/613
49+
#
50+
# extends:
51+
# - '@commitlint/config-conventional'
52+
rules:
53+
body-leading-blank: [1, always]
54+
body-max-line-length: [2, always, 100]
55+
footer-leading-blank: [1, always]
56+
footer-max-line-length: [2, always, 100]
57+
header-max-length: [2, always, 100]
58+
subject-case:
59+
- 2
60+
- never
61+
- [sentence-case, start-case, pascal-case, upper-case]
62+
subject-empty: [2, never]
63+
subject-full-stop: [2, never, "."]
64+
type-case: [2, always, lower-case]
65+
type-empty: [2, never]
66+
type-enum:
67+
- 2
68+
- always
69+
- [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]
70+
```

commitlint.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)