Skip to content

Commit bf3d3fe

Browse files
authored
chore: grooming project (#1)
1 parent 3d368d5 commit bf3d3fe

30 files changed

+5978
-1215
lines changed

.branch-name-list.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"branchNameLinter": {
3+
"prefixes": [
4+
"feat",
5+
"fix",
6+
"docs",
7+
"style",
8+
"refactor",
9+
"test",
10+
"chore",
11+
"perf",
12+
"build",
13+
"ci",
14+
"revert",
15+
"localize",
16+
"bump"
17+
],
18+
"suggestions": {
19+
"feature": "feat",
20+
"fixing": "fix",
21+
"document": "doc",
22+
"styling": "style",
23+
"refactoring": "refactor",
24+
"testing": "test",
25+
"performance": "perf",
26+
"reverting": "revert",
27+
"localise": "localize"
28+
},
29+
"banned": ["wip"],
30+
"skip": [],
31+
"disallowed": ["master", "main", "develop", "staging"],
32+
"separator": "/",
33+
"msgBranchBanned": "Branches with the name \"%s\" are not allowed.",
34+
"msgBranchDisallowed": "Pushing to \"%s\" is not allowed, use git-flow.",
35+
"msgPrefixNotAllowed": "Branch prefix \"%s\" is not allowed.",
36+
"msgPrefixSuggestion": "Instead of \"%s\" try \"%s\".",
37+
"msgseparatorRequired": "Branch \"%s\" must contain a separator \"%s\"."
38+
}
39+
}

.commitlintrc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"],
3+
"rules": {
4+
"type-enum": [
5+
2,
6+
"always",
7+
[
8+
"feat",
9+
"fix",
10+
"docs",
11+
"style",
12+
"refactor",
13+
"test",
14+
"chore",
15+
"perf",
16+
"build",
17+
"ci",
18+
"revert",
19+
"localize",
20+
"bump"
21+
]
22+
]
23+
}
24+
}

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
indent_style = space
7+
indent_size = 2

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
Thanks for your contribution!
3+
Please check the following to make sure your contribution follows our guideline when developing.
4+
-->
5+
6+
## Description
7+
8+
<!-- Describe your changes in detail -->
9+
10+
## Related Issues
11+
12+
<!-- Link any related issues here -->
13+
14+
- Closes #(issue number)
15+
16+
## Testing
17+
18+
- [ ] I have tested these changes locally
19+
- [ ] I have added/updated tests as needed
20+
- [ ] All existing tests pass
21+
22+
## Screenshots/Recordings
23+
24+
<!-- Add screenshots or recordings if your changes affect the UI -->

.github/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
day: "monday"
7+
interval: "monthly"
8+
time: "09:00"
9+
timezone: "Australia/Melbourne"
10+
- package-ecosystem: "npm"
11+
directory: "/"
12+
schedule:
13+
day: "monday"
14+
interval: "monthly"
15+
time: "09:00"
16+
timezone: "Australia/Melbourne"
17+
pull-request-branch-name:
18+
separator: "-"
19+
open-pull-requests-limit: 99
20+
target-branch: main
21+
ignore:
22+
- dependency-name: "husky"
23+
versions:
24+
- ">= 7"
25+
- dependency-name: "@types/node"
26+
versions:
27+
- ">= 22"
28+
commit-message:
29+
prefix: chore
30+
include: scope

.github/labeler.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"type: feature ✨":
2+
title: '^feat(\(.+\))?:.*'
3+
"type: fix 🐞":
4+
title: '^fix(\(.+\))?:.*'
5+
"type: docs 📋":
6+
title: '^docs(\(.+\))?:.*'
7+
"type: style 🎨":
8+
title: '^style(\(.+\))?:.*'
9+
"type: refactor 🔧":
10+
title: '^refactor(\(.+\))?:.*'
11+
"type: test 🧪":
12+
title: '^test(\(.+\))?:.*'
13+
"type: chore 🧹":
14+
title: '^chore(\(.+\))?:.*'
15+
"type: perf ⚡":
16+
title: '^perf(\(.+\))?:.*'
17+
"type: build 🔨":
18+
title: '^build(\(.+\))?:.*'
19+
"type: ci ⚙️":
20+
title: '^ci(\(.+\))?:.*'
21+
"type: revert ↩️":
22+
title: '^revert(\(.+\))?:.*'
23+
"type: localize 🌐":
24+
title: '^localize(\(.+\))?:.*'
25+
"type: bump 📦":
26+
title: '^bump(\(.+\))?:.*'

.github/workflows/docker-build.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Docker Build & Push
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag-name:
7+
description: "The tag name to build (e.g., v1.0.0)"
8+
required: true
9+
type: string
10+
is-dev-release:
11+
description: "Whether this is a dev/pre-release"
12+
required: false
13+
type: boolean
14+
default: false
15+
workflow_dispatch:
16+
inputs:
17+
tag-name:
18+
description: "The tag name to build (e.g., v1.0.0)"
19+
required: true
20+
type: string
21+
is-dev-release:
22+
description: "Whether this is a dev/pre-release"
23+
required: false
24+
type: boolean
25+
default: false
26+
27+
jobs:
28+
docker:
29+
name: Build & Push Docker Image
30+
runs-on: ubuntu-latest
31+
timeout-minutes: 30
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0 # Fetch all history and tags
37+
38+
- name: Checkout specific tag
39+
run: |
40+
TAG_NAME="${{ inputs.tag-name }}"
41+
echo "Checking out tag: $TAG_NAME"
42+
git checkout $TAG_NAME
43+
44+
# Verify we're on the correct tag
45+
CURRENT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "no-tag")
46+
echo "Current tag after checkout: $CURRENT_TAG"
47+
48+
if [ "$CURRENT_TAG" != "$TAG_NAME" ]; then
49+
echo "ERROR: Failed to checkout tag $TAG_NAME. Currently on: $CURRENT_TAG"
50+
exit 1
51+
fi
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: "22"
57+
cache: "npm"
58+
59+
- name: Install dependencies
60+
run: npm ci
61+
62+
- name: Build project
63+
run: npm run build
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Set up QEMU
69+
uses: docker/setup-qemu-action@v3
70+
71+
- name: Login to Docker Hub
72+
uses: docker/login-action@v3
73+
with:
74+
username: ${{ secrets.DOCKER_USERNAME }}
75+
password: ${{ secrets.DOCKER_PASSWORD }}
76+
77+
- name: Extract version and build metadata
78+
id: meta
79+
run: |
80+
TAG_NAME="${{ inputs.tag-name }}"
81+
PACKAGE_VERSION="${TAG_NAME#v}"
82+
GIT_HASH=$(git rev-parse --short HEAD)
83+
IS_DEV_RELEASE=${{ inputs.is-dev-release }}
84+
85+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
86+
echo "GIT_HASH=$GIT_HASH" >> $GITHUB_ENV
87+
echo "IS_DEV_RELEASE=$IS_DEV_RELEASE" >> $GITHUB_ENV
88+
89+
echo "Package Version: $PACKAGE_VERSION"
90+
echo "Git Hash: $GIT_HASH"
91+
echo "Is Dev Release: $IS_DEV_RELEASE"
92+
93+
- name: Generate Docker tags and labels
94+
id: docker-meta
95+
uses: docker/metadata-action@v5
96+
with:
97+
images: chrisleekr/test-github-actions
98+
tags: |
99+
type=raw,value=${{ env.PACKAGE_VERSION }}
100+
type=raw,value=latest,enable=${{ env.IS_DEV_RELEASE == 'false' }}
101+
labels: |
102+
org.opencontainers.image.version=${{ env.PACKAGE_VERSION }}
103+
org.opencontainers.image.revision=${{ env.GIT_HASH }}
104+
105+
- name: Build and push Docker image - Dev/Alpha
106+
if: env.IS_DEV_RELEASE == 'true'
107+
uses: docker/build-push-action@v6
108+
with:
109+
context: .
110+
file: Dockerfile
111+
platforms: linux/arm64
112+
push: true
113+
target: production-stage
114+
cache-from: type=gha
115+
cache-to: type=gha,mode=max
116+
build-args: |
117+
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
118+
GIT_HASH=${{ env.GIT_HASH }}
119+
NODE_ENV=production
120+
tags: ${{ steps.docker-meta.outputs.tags }}
121+
labels: ${{ steps.docker-meta.outputs.labels }}
122+
123+
- name: Build and push Docker image - Production
124+
if: env.IS_DEV_RELEASE == 'false'
125+
uses: docker/build-push-action@v6
126+
with:
127+
context: .
128+
file: Dockerfile
129+
platforms: linux/amd64,linux/arm64
130+
push: true
131+
target: production-stage
132+
cache-from: type=gha
133+
cache-to: type=gha,mode=max
134+
build-args: |
135+
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
136+
GIT_HASH=${{ env.GIT_HASH }}
137+
NODE_ENV=production
138+
tags: ${{ steps.docker-meta.outputs.tags }}
139+
labels: ${{ steps.docker-meta.outputs.labels }}
140+
141+
- name: Image digest
142+
run: echo "Image pushed with digest ${{ steps.docker-meta.outputs.digest }}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Generate Labels"
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
label:
9+
name: "Label PR based on title"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: srvaroa/labeler@v1
13+
env:
14+
GITHUB_TOKEN: ${{ github.token }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Merge Dependencies"
2+
3+
# https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/
4+
on: [pull_request_target]
5+
6+
permissions:
7+
pull-requests: write
8+
contents: write
9+
10+
jobs:
11+
auto-merge:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
14+
steps:
15+
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request#about-auto-merge
16+
- name: "Enable auto-merge on PR"
17+
run: gh pr merge --auto --squash "$PR_URL"
18+
env:
19+
PR_URL: ${{ github.event.pull_request.html_url }}
20+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
- name: "Approve PR"
23+
run: gh pr review --approve "$PR_URL"
24+
env:
25+
PR_URL: ${{github.event.pull_request.html_url}}
26+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)