Skip to content

Commit de52e7d

Browse files
committed
♻️ Extract the values maybe customized for each GitHub project as the common usages.
1 parent 0c2a3d6 commit de52e7d

File tree

4 files changed

+133
-44
lines changed

4 files changed

+133
-44
lines changed

.github/workflows/release-staging.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ concurrency:
2222
group: release-staging-${{ github.ref_name }}
2323
cancel-in-progress: false
2424

25+
env:
26+
# Project Configuration
27+
PROJECT_NAME: ${{ vars.PROJECT_NAME || github.event.repository.name }}
28+
BASE_BRANCH: ${{ vars.BASE_BRANCH || 'master' }}
29+
PACKAGE_NAME: ${{ vars.PACKAGE_NAME || github.event.repository.name }}
30+
31+
# Docker Configuration
32+
DOCKER_HEALTH_CHECK_PORT: ${{ vars.DOCKER_HEALTH_CHECK_PORT || '8000' }}
33+
DOCKER_HEALTH_CHECK_PATH: ${{ vars.DOCKER_HEALTH_CHECK_PATH || '/health' }}
34+
DOCKER_REGISTRY_DOCKERHUB: ${{ vars.DOCKER_REGISTRY_DOCKERHUB || 'docker.io' }}
35+
DOCKER_REGISTRY_GHCR: ${{ vars.DOCKER_REGISTRY_GHCR || 'ghcr.io' }}
36+
37+
# Application Configuration
38+
APP_ENV_VAR_NAME: ${{ vars.APP_ENV_VAR_NAME || 'API_TOKEN' }}
39+
APP_ENV_VAR_VALUE: ${{ vars.APP_ENV_VAR_VALUE || 'your_token' }}
40+
41+
# Documentation Configuration
42+
DOCS_PREVIEW_BRANCH: ${{ vars.DOCS_PREVIEW_BRANCH || 'docs-preview' }}
43+
2544
jobs:
2645
compute-version:
2746
name: Compute Staging Version
@@ -100,27 +119,31 @@ jobs:
100119
registry-token: ${{ secrets.DOCKERHUB_TOKEN }}
101120
with:
102121
operation: 'push'
103-
registry: 'docker.io'
122+
registry: ${{ env.DOCKER_REGISTRY_DOCKERHUB }}
104123
version: ${{ needs.compute-version.outputs.rc_version }}
105124
checkout-sha: ${{ github.sha }}
106125
enable-sbom: true
107126
enable-signing: true
108-
health-check-port: '8000'
109-
health-check-path: '/health'
127+
health-check-port: ${{ env.DOCKER_HEALTH_CHECK_PORT }}
128+
health-check-path: ${{ env.DOCKER_HEALTH_CHECK_PATH }}
129+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
130+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
110131

111132
ghcr-rc:
112133
name: Staging Release to GHCR
113134
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docker_operations.yaml@master
114135
needs: [compute-version, build_git-tag_and_create_github-release]
115136
with:
116137
operation: 'push'
117-
registry: 'ghcr.io'
138+
registry: ${{ env.DOCKER_REGISTRY_GHCR }}
118139
version: ${{ needs.compute-version.outputs.rc_version }}
119140
checkout-sha: ${{ github.sha }}
120141
enable-sbom: true
121142
enable-signing: true
122-
health-check-port: '8000'
123-
health-check-path: '/health'
143+
health-check-port: ${{ env.DOCKER_HEALTH_CHECK_PORT }}
144+
health-check-path: ${{ env.DOCKER_HEALTH_CHECK_PATH }}
145+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
146+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
124147

125148
docs-preview:
126149
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docs_operations.yaml@master
@@ -129,7 +152,7 @@ jobs:
129152
operation: 'deploy-preview'
130153
version: ${{ needs.compute-version.outputs.rc_version }}
131154
checkout-sha: ${{ github.sha }}
132-
preview-branch: 'docs-preview'
155+
preview-branch: ${{ env.DOCS_PREVIEW_BRANCH }}
133156
upload-artifacts: true
134157

135158
staging-summary:
@@ -150,7 +173,7 @@ jobs:
150173
echo "📦 Staging Artifacts:"
151174
echo "- Base Version: ${{ needs.compute-version.outputs.version }}"
152175
echo "- RC Version: ${{ needs.compute-version.outputs.rc_version }}"
153-
echo "- TestPyPI: https://test.pypi.org/project/clickup-mcp-server/${{ needs.compute-version.outputs.version }}/"
176+
echo "- TestPyPI: https://test.pypi.org/project/${{ env.PROJECT_NAME }}/${{ needs.compute-version.outputs.version }}/"
154177
echo "- GHCR RC Image: ghcr.io/${{ github.repository }}:${{ needs.compute-version.outputs.rc_version }}"
155178
echo "- Docs Preview: docs-preview branch"
156179
echo ""
@@ -163,10 +186,10 @@ jobs:
163186
echo ""
164187
echo "🧪 Testing Instructions:"
165188
echo "1. Install from TestPyPI:"
166-
echo " pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ clickup-mcp-server==${{ needs.compute-version.outputs.version }}"
189+
echo " pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ${{ env.PROJECT_NAME }}==${{ needs.compute-version.outputs.version }}"
167190
echo ""
168191
echo "2. Test RC Docker image:"
169-
echo " docker run -p 8000:8000 -e CLICKUP_API_TOKEN=your_token ghcr.io/${{ github.repository }}:${{ needs.compute-version.outputs.rc_version }}"
192+
echo " docker run -p ${{ env.DOCKER_HEALTH_CHECK_PORT }}:${{ env.DOCKER_HEALTH_CHECK_PORT }} -e ${{ env.APP_ENV_VAR_NAME }}=${{ env.APP_ENV_VAR_VALUE }} ghcr.io/${{ github.repository }}:${{ needs.compute-version.outputs.rc_version }}"
170193
echo ""
171194
echo "3. Review documentation preview in docs-preview branch"
172195
echo ""

.github/workflows/release-validate.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release Validation (Dry Run)
33
on:
44
pull_request:
55
branches:
6-
- <your_base_branch>
6+
- <your_base_branch> # Replace with your main branch (e.g., master, main)
77
paths:
88
- .github/tag_and_release/**
99
- pyproject.toml
@@ -35,6 +35,26 @@ concurrency:
3535
group: release-validate-${{ github.ref }}
3636
cancel-in-progress: true
3737

38+
env:
39+
# Project Configuration
40+
PROJECT_NAME: ${{ vars.PROJECT_NAME || github.event.repository.name }}
41+
BASE_BRANCH: ${{ vars.BASE_BRANCH || 'master' }}
42+
PACKAGE_NAME: ${{ vars.PACKAGE_NAME || github.event.repository.name }}
43+
44+
# Docker Configuration
45+
DOCKER_HEALTH_CHECK_PORT: ${{ vars.DOCKER_HEALTH_CHECK_PORT || '8000' }}
46+
DOCKER_HEALTH_CHECK_PATH: ${{ vars.DOCKER_HEALTH_CHECK_PATH || '/health' }}
47+
DOCKER_REGISTRY_DOCKERHUB: ${{ vars.DOCKER_REGISTRY_DOCKERHUB || 'docker.io' }}
48+
DOCKER_REGISTRY_GHCR: ${{ vars.DOCKER_REGISTRY_GHCR || 'ghcr.io' }}
49+
50+
# Application Configuration
51+
APP_ENV_VAR_NAME: ${{ vars.APP_ENV_VAR_NAME || 'API_TOKEN' }}
52+
APP_ENV_VAR_VALUE: ${{ vars.APP_ENV_VAR_VALUE || 'test_token' }}
53+
54+
# Validation Configuration
55+
VALIDATION_VERSION: ${{ vars.VALIDATION_VERSION || '1.0.0-validation' }}
56+
VALIDATION_TEST_VERSION: ${{ vars.VALIDATION_TEST_VERSION || 'validation-test' }}
57+
3858
jobs:
3959
intent-parse:
4060
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_parse_release_intent.yaml@master
@@ -49,7 +69,7 @@ jobs:
4969
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_build_git-tag_and_create_github-release_v2.yaml@master
5070
needs: intent-parse
5171
with:
52-
version: "1.0.0-validation" # Test version for validation
72+
version: ${{ env.VALIDATION_VERSION }} # Test version for validation
5373
debug_mode: true
5474
secrets:
5575
github_auth_token: ${{ secrets.GITHUB_TOKEN }}
@@ -67,25 +87,29 @@ jobs:
6787
needs: build_git-tag_and_create_github-release
6888
with:
6989
operation: 'test'
70-
registry: 'docker.io'
90+
registry: ${{ env.DOCKER_REGISTRY_DOCKERHUB }}
7191
image-name: ${{ github.repository }}
72-
version: 'validation-test'
73-
health-check-port: '8000'
74-
health-check-path: '/health'
92+
version: ${{ env.VALIDATION_TEST_VERSION }}
93+
health-check-port: ${{ env.DOCKER_HEALTH_CHECK_PORT }}
94+
health-check-path: ${{ env.DOCKER_HEALTH_CHECK_PATH }}
7595
enable-signing: true
96+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
97+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
7698

7799
docker-build-ghcr:
78100
name: Validate GHCR Build
79101
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docker_operations.yaml@master
80102
needs: build_git-tag_and_create_github-release
81103
with:
82104
operation: 'test'
83-
registry: 'ghcr.io'
105+
registry: ${{ env.DOCKER_REGISTRY_GHCR }}
84106
image-name: ${{ github.repository }}
85-
version: 'validation-test'
86-
health-check-port: '8000'
87-
health-check-path: '/health'
107+
version: ${{ env.VALIDATION_TEST_VERSION }}
108+
health-check-port: ${{ env.DOCKER_HEALTH_CHECK_PORT }}
109+
health-check-path: ${{ env.DOCKER_HEALTH_CHECK_PATH }}
88110
enable-signing: true
111+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
112+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
89113

90114
docs-build:
91115
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docs_operations.yaml@master
@@ -100,11 +124,13 @@ jobs:
100124
needs: [docker-build-dockerhub, docker-build-ghcr]
101125
with:
102126
operation: 'security-scan'
103-
registry: 'docker.io' # Use DockerHub build for security scan
127+
registry: ${{ env.DOCKER_REGISTRY_DOCKERHUB }} # Use DockerHub build for security scan
104128
image-name: ${{ github.repository }}
105-
version: 'validation-test'
129+
version: ${{ env.VALIDATION_TEST_VERSION }}
106130
enable-sbom: true
107131
enable-signing: true
132+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
133+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
108134

109135
validation-summary:
110136
name: Validation Summary

.github/workflows/release.yml

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: release
44
on:
55
push:
66
branches:
7-
- <your_base_branch>
7+
- <your_base_branch> # Replace with your main branch (e.g., master, main)
88
paths:
99
- .github/tag_and_release/release-**
1010
workflow_dispatch:
@@ -56,6 +56,32 @@ concurrency:
5656
group: release-${{ github.ref_name }}
5757
cancel-in-progress: false
5858

59+
env:
60+
# Project Configuration
61+
PROJECT_NAME: ${{ vars.PROJECT_NAME || github.event.repository.name }}
62+
BASE_BRANCH: ${{ vars.BASE_BRANCH || 'master' }}
63+
PACKAGE_NAME: ${{ vars.PACKAGE_NAME || github.event.repository.name }}
64+
65+
# Git Configuration
66+
GIT_COMMIT_EMAIL: ${{ vars.GIT_COMMIT_EMAIL || '[email protected]' }}
67+
GIT_COMMIT_NAME: ${{ vars.GIT_COMMIT_NAME || 'GitHub Action' }}
68+
69+
# Docker Configuration
70+
DOCKER_HEALTH_CHECK_PORT: ${{ vars.DOCKER_HEALTH_CHECK_PORT || '8000' }}
71+
DOCKER_HEALTH_CHECK_PATH: ${{ vars.DOCKER_HEALTH_CHECK_PATH || '/health' }}
72+
DOCKER_REGISTRY_DOCKERHUB: ${{ vars.DOCKER_REGISTRY_DOCKERHUB || 'docker.io' }}
73+
DOCKER_REGISTRY_GHCR: ${{ vars.DOCKER_REGISTRY_GHCR || 'ghcr.io' }}
74+
75+
# Application Configuration
76+
APP_ENV_VAR_NAME: ${{ vars.APP_ENV_VAR_NAME || 'API_TOKEN' }}
77+
APP_ENV_VAR_VALUE: ${{ vars.APP_ENV_VAR_VALUE || 'test_token' }}
78+
79+
# Documentation Configuration
80+
DOCS_PREVIEW_BRANCH: ${{ vars.DOCS_PREVIEW_BRANCH || 'docs-preview' }}
81+
DOCS_CI_CD_PATH: ${{ vars.DOCS_CI_CD_PATH || 'docs/contents/development/ci-cd.mdx' }}
82+
DOCS_INSTALLATION_PATH: ${{ vars.DOCS_INSTALLATION_PATH || 'docs/contents/document/installation.md' }}
83+
DOCS_README_PATH: ${{ vars.DOCS_README_PATH || 'docs/contents/document/README.md' }}
84+
5985
jobs:
6086
intent:
6187
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_parse_release_intent.yaml@master
@@ -213,8 +239,8 @@ jobs:
213239

214240
- name: Configure git
215241
run: |
216-
git config --global user.email "[email protected]"
217-
git config --global user.name "GitHub Action"
242+
git config --global user.email "${{ env.GIT_COMMIT_EMAIL }}"
243+
git config --global user.name "${{ env.GIT_COMMIT_NAME }}"
218244
219245
- name: Bump version with uv
220246
id: bump
@@ -251,31 +277,31 @@ jobs:
251277
DOCS_UPDATED=false
252278
253279
# Update main CI/CD documentation if it exists
254-
if [ -f "docs/contents/development/ci-cd.mdx" ]; then
280+
if [ -f "${{ env.DOCS_CI_CD_PATH }}" ]; then
255281
# Update any version references in installation examples, if they exist
256-
if grep -q "clickup-mcp-server" "docs/contents/development/ci-cd.mdx"; then
282+
if grep -q "${{ env.PROJECT_NAME }}" "${{ env.DOCS_CI_CD_PATH }}"; then
257283
# This is just a placeholder - adjust pattern as needed for actual version references
258284
echo "Found version references in ci-cd.mdx to update"
259285
DOCS_UPDATED=true
260286
fi
261287
fi
262288
263289
# Update package installation docs if they exist
264-
if [ -f "docs/contents/document/installation.md" ]; then
265-
if grep -q "pip install.*clickup-mcp-server" "docs/contents/document/installation.md"; then
266-
sed -i.bak "s/clickup-mcp-server==[0-9]\+\.[0-9]\+\.[0-9]\+/clickup-mcp-server==$NEW_VERSION/g" "docs/contents/document/installation.md"
267-
rm -f "docs/contents/document/installation.md.bak" 2>/dev/null || true
290+
if [ -f "${{ env.DOCS_INSTALLATION_PATH }}" ]; then
291+
if grep -q "pip install.*${{ env.PROJECT_NAME }}" "${{ env.DOCS_INSTALLATION_PATH }}"; then
292+
sed -i.bak "s/${{ env.PROJECT_NAME }}==[0-9]\+\.[0-9]\+\.[0-9]\+/${{ env.PROJECT_NAME }}==$NEW_VERSION/g" "${{ env.DOCS_INSTALLATION_PATH }}"
293+
rm -f "${{ env.DOCS_INSTALLATION_PATH }}.bak" 2>/dev/null || true
268294
echo "Updated installation documentation with new version"
269295
DOCS_UPDATED=true
270296
fi
271297
fi
272298
273299
# Update README if it has version references
274-
if [ -f "docs/contents/document/README.md" ]; then
275-
if grep -q "clickup-mcp-server" "docs/contents/document/README.md"; then
300+
if [ -f "${{ env.DOCS_README_PATH }}" ]; then
301+
if grep -q "${{ env.PROJECT_NAME }}" "${{ env.DOCS_README_PATH }}"; then
276302
# Update version references in README examples
277-
sed -i.bak "s/clickup-mcp-server==[0-9]\+\.[0-9]\+\.[0-9]\+/clickup-mcp-server==$NEW_VERSION/g" "docs/contents/document/README.md"
278-
rm -f "docs/contents/document/README.md.bak" 2>/dev/null || true
303+
sed -i.bak "s/${{ env.PROJECT_NAME }}==[0-9]\+\.[0-9]\+\.[0-9]\+/${{ env.PROJECT_NAME }}==$NEW_VERSION/g" "${{ env.DOCS_README_PATH }}"
304+
rm -f "${{ env.DOCS_README_PATH }}.bak" 2>/dev/null || true
279305
echo "Updated README documentation with new version"
280306
DOCS_UPDATED=true
281307
fi
@@ -288,13 +314,13 @@ jobs:
288314
# Add documentation files if they were updated
289315
if [ "$DOCS_UPDATED" = true ]; then
290316
# Add any updated documentation files
291-
if [ -f "docs/contents/document/installation.md" ]; then
292-
git add "docs/contents/document/installation.md"
293-
FILES_TO_COMMIT="$FILES_TO_COMMIT docs/contents/document/installation.md"
317+
if [ -f "${{ env.DOCS_INSTALLATION_PATH }}" ]; then
318+
git add "${{ env.DOCS_INSTALLATION_PATH }}"
319+
FILES_TO_COMMIT="$FILES_TO_COMMIT ${{ env.DOCS_INSTALLATION_PATH }}"
294320
fi
295-
if [ -f "docs/contents/document/README.md" ]; then
296-
git add "docs/contents/document/README.md"
297-
FILES_TO_COMMIT="$FILES_TO_COMMIT docs/contents/document/README.md"
321+
if [ -f "${{ env.DOCS_README_PATH }}" ]; then
322+
git add "${{ env.DOCS_README_PATH }}"
323+
FILES_TO_COMMIT="$FILES_TO_COMMIT ${{ env.DOCS_README_PATH }}"
298324
fi
299325
COMMIT_MESSAGE="⬆️ chore: bump version to $NEW_VERSION, sync uv.lock, and update docs"
300326
echo "Documentation files updated and will trigger documentation workflow"
@@ -362,11 +388,13 @@ jobs:
362388
registry-token: ${{ secrets.DOCKERHUB_TOKEN }}
363389
with:
364390
operation: 'push'
365-
registry: 'docker.io'
391+
registry: ${{ env.DOCKER_REGISTRY_DOCKERHUB }}
366392
version: ${{ needs.bump_version.outputs.version }}
367393
checkout-sha: ${{ needs.bump_version.outputs.new_sha }}
368394
enable-sbom: true
369395
enable-signing: true
396+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
397+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
370398

371399
release_docker_ghcr:
372400
name: Release to GHCR
@@ -375,11 +403,13 @@ jobs:
375403
if: needs.intent.outputs.do_release == 'true' && needs.intent.outputs.docker != 'skip'
376404
with:
377405
operation: 'push'
378-
registry: 'ghcr.io'
406+
registry: ${{ env.DOCKER_REGISTRY_GHCR }}
379407
version: ${{ needs.bump_version.outputs.version }}
380408
checkout-sha: ${{ needs.bump_version.outputs.new_sha }}
381409
enable-sbom: true
382410
enable-signing: true
411+
app-env-var-name: ${{ env.APP_ENV_VAR_NAME }}
412+
app-env-var-value: ${{ env.APP_ENV_VAR_VALUE }}
383413

384414
release_docs:
385415
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docs_operations.yaml@master

.github/workflows/rw_docker_operations.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ on:
5858
required: false
5959
default: ''
6060
type: string
61+
app-env-var-name:
62+
description: 'Application environment variable name for testing'
63+
required: false
64+
default: 'API_TOKEN'
65+
type: string
66+
app-env-var-value:
67+
description: 'Application environment variable value for testing'
68+
required: false
69+
default: 'test_token'
70+
type: string
6171

6272
secrets:
6373
dockerhub-user:
@@ -177,7 +187,7 @@ jobs:
177187
# Start container in background
178188
docker run -d --name test-container \
179189
-p ${{ inputs.health-check-port }}:${{ inputs.health-check-port }} \
180-
-e CLICKUP_API_TOKEN=test_token \
190+
-e ${{ inputs.app-env-var-name }}=${{ inputs.app-env-var-value }} \
181191
$IMAGE_TAG
182192
183193
# Wait for container to be ready and test health endpoint

0 commit comments

Comments
 (0)