|
| 1 | +when: |
| 2 | + - event: [push, manual] |
| 3 | + branch: |
| 4 | + exclude: [main] |
| 5 | + - event: [pull_request] |
| 6 | + # Only run when PR targets development or other branches (not main) |
| 7 | + evaluate: 'CI_COMMIT_TARGET_BRANCH != "main"' |
| 8 | + |
| 9 | +variables: |
| 10 | + - ®istry_url "https://registry.cloud.josa.ngo" |
| 11 | + - &docker_repo "registry.cloud.josa.ngo/library/kutt" |
| 12 | + - &slack_channel "builds" |
| 13 | + # Success message template |
| 14 | + - &success_message > |
| 15 | + ✅ *SUCCESS* - Latest Build #{{ build.number }} |
| 16 | + |
| 17 | + 📁 *Repository:* {{ repo.name }} |
| 18 | + 🌿 *Branch:* {{ build.branch }} |
| 19 | + 📝 *Commit:* {{ truncate build.commit 8 }} |
| 20 | + 👤 *Author:* {{ build.author }} |
| 21 | + |
| 22 | + 🔗 *Links:* |
| 23 | + • <{{ build.link }}|View Build> |
| 24 | + # Failure message template |
| 25 | + - &failure_message > |
| 26 | + ❌ *FAILED* - Latest Build #{{ build.number }} |
| 27 | + |
| 28 | + 📁 *Repository:* {{ repo.name }} |
| 29 | + 🌿 *Branch:* {{ build.branch }} |
| 30 | + 📝 *Commit:* {{ truncate build.commit 8 }} |
| 31 | + 👤 *Author:* {{ build.author }} |
| 32 | + |
| 33 | + 🔗 *Links:* |
| 34 | + • <{{ build.link }}|View Build> |
| 35 | + |
| 36 | +steps: |
| 37 | + # Security check - scan for secrets/credentials |
| 38 | + - name: run-pre-commit-hooks |
| 39 | + image: registry.cloud.josa.ngo/library/pre-commit-runner |
| 40 | + settings: |
| 41 | + args: "--all-files" |
| 42 | + skip: "end-of-file-fixer, yamllint, trailing-whitespace" |
| 43 | + |
| 44 | + # Build latest image (development and other branches) |
| 45 | + - name: build-latest-image |
| 46 | + image: woodpeckerci/plugin-docker-buildx |
| 47 | + settings: |
| 48 | + repo: *docker_repo |
| 49 | + registry: *registry_url |
| 50 | + dockerfile: ./Dockerfile |
| 51 | + tags: |
| 52 | + - ${CI_COMMIT_SHA:-latest} |
| 53 | + - latest |
| 54 | + username: |
| 55 | + from_secret: REGISTRY_USERNAME |
| 56 | + password: |
| 57 | + from_secret: REGISTRY_SECRET |
| 58 | + build_args: |
| 59 | + CI_REPO: "${CI_REPO}" |
| 60 | + CI_REPO_NAME: "${CI_REPO_NAME}" |
| 61 | + CI_REPO_URL: "${CI_REPO_URL}" |
| 62 | + CI_COMMIT_SHA: "${CI_COMMIT_SHA}" |
| 63 | + CI_COMMIT_REF: "${CI_COMMIT_REF}" |
| 64 | + CI_PIPELINE_URL: "${CI_PIPELINE_URL}" |
| 65 | + CI_PIPELINE_CREATED: "${CI_PIPELINE_CREATED}" |
| 66 | + CI_PREV_PIPELINE_URL: "${CI_PREV_PIPELINE_URL}" |
| 67 | + CI_PIPELINE_NUMBER: "${CI_PIPELINE_NUMBER}" |
| 68 | + |
| 69 | + depends_on: |
| 70 | + - run-pre-commit-hooks |
| 71 | + |
| 72 | + # Slack notification for latest build success |
| 73 | + - name: notify-slack-latest-success |
| 74 | + image: plugins/slack |
| 75 | + settings: |
| 76 | + webhook: |
| 77 | + from_secret: SLACK_WEBHOOK |
| 78 | + channel: *slack_channel |
| 79 | + template: *success_message |
| 80 | + when: |
| 81 | + - status: success |
| 82 | + depends_on: |
| 83 | + - run-pre-commit-hooks |
| 84 | + - build-latest-image |
| 85 | + |
| 86 | + # Slack notification for latest build failure |
| 87 | + - name: notify-slack-latest-failure |
| 88 | + image: plugins/slack |
| 89 | + settings: |
| 90 | + webhook: |
| 91 | + from_secret: SLACK_WEBHOOK |
| 92 | + channel: *slack_channel |
| 93 | + template: *failure_message |
| 94 | + when: |
| 95 | + - status: failure |
| 96 | + depends_on: |
| 97 | + - run-pre-commit-hooks |
| 98 | + - build-latest-image |
0 commit comments