Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions .woodpecker/build-latest-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,10 @@ when:
- event: [pull_request]
# Only run when PR targets development or other branches (not main)
evaluate: 'CI_COMMIT_TARGET_BRANCH != "main"'
# Build the source branch
branch:
exclude: [main]
- event: [pull_request]
# Also build latest image when development branch creates PR to main
evaluate: 'CI_COMMIT_TARGET_BRANCH == "main" && CI_COMMIT_BRANCH == "development"'
branch: [development]

variables:
- &docker_repo "josaorg/kutt"
- &slack_channel "builds"
# Docker build arguments template
- &build_args_template
- CI_COMMIT_SHA=${CI_COMMIT_SHA}
- CI_BUILD_NUMBER=${CI_BUILD_NUMBER}
- CI_BUILD_LINK=${CI_BUILD_LINK}
- CI_COMMIT_LINK=${CI_COMMIT_LINK}
- CI_REPO_LINK=${CI_REPO_LINK}
- CI_BUILD_FINISHED=${CI_BUILD_FINISHED}
# Success message template
- &success_message >
✅ *SUCCESS* - Latest Build #{{ build.number }}
Expand All @@ -49,10 +34,11 @@ variables:

steps:
# Security check - scan for secrets/credentials
- name: check-for-leaks
image: zricethezav/gitleaks:v8.18.4
commands:
- gitleaks detect --source . --verbose
- name: run-pre-commit-hooks
image: josaorg/pre-commit-runner
settings:
args: "--all-files"
skip: "end-of-file-fixer, yamllint, trailing-whitespace"

# Build latest image (development and other branches)
- name: build-latest-image
Expand All @@ -67,9 +53,19 @@ steps:
from_secret: DOCKER_HUB_USERNAME
password:
from_secret: DOCKER_HUB_PASSWORD
build_args: *build_args_template
build_args:
CI_REPO: "${CI_REPO}"
CI_REPO_NAME: "${CI_REPO_NAME}"
CI_REPO_URL: "${CI_REPO_URL}"
CI_COMMIT_SHA: "${CI_COMMIT_SHA}"
CI_COMMIT_REF: "${CI_COMMIT_REF}"
CI_PIPELINE_URL: "${CI_PIPELINE_URL}"
CI_PIPELINE_CREATED: "${CI_PIPELINE_CREATED}"
CI_PREV_PIPELINE_URL: "${CI_PREV_PIPELINE_URL}"
CI_PIPELINE_NUMBER: "${CI_PIPELINE_NUMBER}"

depends_on:
- check-for-leaks
- run-pre-commit-hooks

# Slack notification for latest build success
- name: notify-slack-latest-success
Expand All @@ -82,7 +78,7 @@ steps:
when:
- status: success
depends_on:
- check-for-leaks
- run-pre-commit-hooks
- build-latest-image

# Slack notification for latest build failure
Expand All @@ -96,5 +92,5 @@ steps:
when:
- status: failure
depends_on:
- check-for-leaks
- run-pre-commit-hooks
- build-latest-image
36 changes: 19 additions & 17 deletions .woodpecker/build-stable-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ when:
variables:
- &docker_repo "josaorg/kutt"
- &slack_channel "builds"
# Docker build arguments template
- &build_args_template
- CI_COMMIT_SHA=${CI_COMMIT_SHA}
- CI_BUILD_NUMBER=${CI_BUILD_NUMBER}
- CI_BUILD_LINK=${CI_BUILD_LINK}
- CI_COMMIT_LINK=${CI_COMMIT_LINK}
- CI_REPO_LINK=${CI_REPO_LINK}
- CI_BUILD_FINISHED=${CI_BUILD_FINISHED}
# Success message template
- &success_message >
✅ *SUCCESS* - Stable Build #{{ build.number }}
Expand All @@ -43,11 +35,11 @@ variables:
• <{{ build.link }}|View Build>

steps:
# Security check - scan for secrets/credentials
- name: check-for-leaks
image: zricethezav/gitleaks:v8.18.4
commands:
- gitleaks detect --source . --verbose
- name: run-pre-commit-hooks
image: josaorg/pre-commit-runner
settings:
args: "--all-files"
skip: "end-of-file-fixer, yamllint, trailing-whitespace"

# Build stable image (main branch only)
- name: build-stable-image
Expand All @@ -62,9 +54,19 @@ steps:
from_secret: DOCKER_HUB_USERNAME
password:
from_secret: DOCKER_HUB_PASSWORD
build_args: *build_args_template
build_args:
CI_REPO: "${CI_REPO}"
CI_REPO_NAME: "${CI_REPO_NAME}"
CI_REPO_URL: "${CI_REPO_URL}"
CI_COMMIT_SHA: "${CI_COMMIT_SHA}"
CI_COMMIT_REF: "${CI_COMMIT_REF}"
CI_PIPELINE_URL: "${CI_PIPELINE_URL}"
CI_PIPELINE_CREATED: "${CI_PIPELINE_CREATED}"
CI_PREV_PIPELINE_URL: "${CI_PREV_PIPELINE_URL}"
CI_PIPELINE_NUMBER: "${CI_PIPELINE_NUMBER}"

depends_on:
- check-for-leaks
- run-pre-commit-hooks

# Slack notification for stable build success
- name: notify-slack-stable-success
Expand All @@ -77,7 +79,7 @@ steps:
when:
- status: success
depends_on:
- check-for-leaks
- run-pre-commit-hooks
- build-stable-image

# Slack notification for stable build failure
Expand All @@ -91,5 +93,5 @@ steps:
when:
- status: failure
depends_on:
- check-for-leaks
- run-pre-commit-hooks
- build-stable-image