Skip to content

Commit 6e2ee4a

Browse files
committed
ci(github): Add docker
ref: #33 #32
1 parent d8a75a6 commit 6e2ee4a

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed

.centurion/project_status.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"schemaVersion": 1,
3+
"label": "Project Status",
4+
"message": "Active",
5+
"namedLogo": "github",
6+
"color": "green",
7+
"style": "plastic"
8+
}

.github/workflows/docker.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
3+
name: 'Docker'
4+
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.sha }}
8+
cancel-in-progress: true
9+
10+
11+
on:
12+
push:
13+
branches:
14+
- '*'
15+
tags:
16+
- '*'
17+
18+
env:
19+
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2 # see https://github.com/nofusscomputing/action_python/issues/10
20+
DOCKER_BUILD_REGISTRY: ghcr.io
21+
DOCKER_BUILD_IMAGE_NAME: "${{ github.repository }}"
22+
DOCKER_BUILD_IMAGE_TAG: ${{ github.sha }}
23+
DOCKER_PUBLISH_REGISTRY: "docker.io/nofusscomputing"
24+
DOCKER_PUBLISH_IMAGE_NAME: "bind"
25+
DOCKER_PUBLISH_USERNAME: ${{ secrets.NFC_DOCKERHUB_USERNAME }}
26+
DOCKER_PUBLISH_PASSWORD: ${{ secrets.NFC_DOCKERHUB_TOKEN }}
27+
28+
DOCKER_FILE: dockerfile
29+
30+
jobs:
31+
32+
33+
docker-build:
34+
runs-on: ubuntu-latest
35+
name: Build Image
36+
steps:
37+
38+
39+
- uses: actions/checkout@v4
40+
41+
42+
- name: Log into GHCR Registry
43+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
44+
with:
45+
registry: ${{ env.DOCKER_BUILD_REGISTRY }}
46+
username: ${{ env.DOCKER_BUILD_USERNAME }}
47+
password: ${{ env.DOCKER_BUILD_PASSWORD }}
48+
49+
50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v3
52+
with:
53+
image: tonistiigi/binfmt:latest
54+
55+
56+
- name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v3
58+
59+
60+
- name: Build and push
61+
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
62+
uses: docker/build-push-action@v6
63+
with:
64+
platforms: linux/amd64,linux/arm64
65+
push: true
66+
tags: ${{ env.DOCKER_BUILD_REGISTRY }}/${{ env.DOCKER_BUILD_IMAGE_NAME }}:${{ github.sha }}
67+
provenance: false
68+
sbom: false
69+
70+
71+
- name: Log into Publish Registry
72+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
73+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
74+
with:
75+
registry: ${{ env.DOCKER_PUBLISH_REGISTRY }}
76+
username: ${{ env.DOCKER_PUBLISH_USERNAME }}
77+
password: ${{ env.DOCKER_PUBLISH_PASSWORD }}
78+
79+
80+
- name: Build and push tagged
81+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
82+
uses: docker/build-push-action@v6
83+
with:
84+
platforms: linux/amd64,linux/arm64
85+
push: true
86+
tags: |
87+
${{ env.DOCKER_BUILD_REGISTRY }}/${{ env.DOCKER_BUILD_IMAGE_NAME }}:${{ github.sha }}
88+
${{ env.DOCKER_BUILD_REGISTRY }}/${{ env.DOCKER_BUILD_IMAGE_NAME }}:${{ github.ref_name }}
89+
${{ env.DOCKER_BUILD_REGISTRY }}/${{ env.DOCKER_BUILD_IMAGE_NAME }}:latest
90+
${{ env.DOCKER_PUBLISH_REGISTRY }}/${{ env.DOCKER_PUBLISH_IMAGE_NAME }}:${{ github.sha }}
91+
${{ env.DOCKER_PUBLISH_REGISTRY }}/${{ env.DOCKER_PUBLISH_IMAGE_NAME }}:${{ github.ref_name }}
92+
${{ env.DOCKER_PUBLISH_REGISTRY }}/${{ env.DOCKER_PUBLISH_IMAGE_NAME }}:latest
93+
provenance: false
94+
sbom: false
95+
96+
97+
docker-publish:
98+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
99+
runs-on: ubuntu-latest
100+
needs:
101+
- docker-build
102+
name: Publish
103+
steps:
104+
105+
106+
- name: Append GH Release Body
107+
id: release
108+
uses: softprops/action-gh-release@v2
109+
with:
110+
append_body: true
111+
draft: false
112+
body: |
113+
### Images part of this release
114+
115+
The following images were built and published:
116+
117+
- `docker pull ${{ env.DOCKER_PUBLISH_REGISTRY }}/${{ env.DOCKER_PUBLISH_IMAGE_NAME }}:${{ steps.tag-image.outputs.mutable_tag_name }}`
118+
- `docker pull ${{ env.DOCKER_PUBLISH_REGISTRY }}/${{ env.DOCKER_PUBLISH_IMAGE_NAME }}:${{ env.DOCKER_TAG_IMAGE_TAG_SOURCE }}`
119+
- `docker pull ${{ env.DOCKER_PUBLISH_REGISTRY }}/${{ env.DOCKER_PUBLISH_IMAGE_NAME }}:${{ github.ref_name }}`

.github/workflows/release.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
3+
name: 'Release'
4+
5+
6+
on:
7+
push:
8+
tags:
9+
- '*'
10+
11+
12+
env:
13+
# ACTIONS_RUNNER_DEBUG: "true"
14+
# ACTIONS_STEP_DEBUG: "true"
15+
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
16+
17+
18+
jobs:
19+
20+
21+
create:
22+
name: 'Create'
23+
if: startsWith(github.ref, 'refs/tags/')
24+
runs-on: ubuntu-latest
25+
steps:
26+
27+
28+
- name: Trace
29+
shell: bash
30+
run: |
31+
export
32+
33+
34+
- name: Install Commitizen
35+
shell: bash
36+
run: |
37+
pip install \
38+
commitizen==3.28.0
39+
40+
41+
- name: Checkout Code
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
fetch-tags: true
46+
token: ${{ secrets.WORKFLOW_TOKEN }}
47+
ref: ${{ github.ref_name }}
48+
49+
50+
- name: Create Incremental Changelog
51+
shell: bash
52+
run: |
53+
export PREV_GIT_TAG="$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)";
54+
export CURR_GIT_TAG="${{ github.ref_name }}";
55+
56+
cz changelog --dry-run --merge-prerelease --unreleased-version "$PREV_GIT_TAG" "$CURR_GIT_TAG" > changelog-release.md;
57+
58+
59+
- name: Create Draft GH Release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
name: ${{ github.ref_name }}
63+
tag_name: ${{ github.ref_name }}
64+
body_path: changelog-release.md
65+
make_latest: true
66+
prerelease: false
67+
draft: true

0 commit comments

Comments
 (0)