Skip to content

Commit d8c121c

Browse files
committed
Simplify Drone pipeline to single pipeline with sequential steps
- Combine test, build, and deploy into one pipeline - Remove unnecessary pipeline dependencies - Simplify change detection logic - Fix typo: DevOps -> DevDocs team in README
1 parent 70c4b21 commit d8c121c

2 files changed

Lines changed: 49 additions & 87 deletions

File tree

github-metrics/.drone.yml

Lines changed: 48 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,57 @@
11
---
22
kind: pipeline
33
type: kubernetes
4-
name: github-metrics-test
4+
name: github-metrics
55

66
trigger:
77
branch:
8-
- main
8+
- main
99
event:
10-
- push # Runs when PR is merged to main
11-
- pull_request # Also runs on PRs for early feedback
10+
- push
1211

1312
steps:
14-
- name: check-changes
15-
image: alpine/git
16-
commands:
17-
- |
18-
# Check if any files in github-metrics/ directory changed
19-
if [ "$DRONE_BUILD_EVENT" = "pull_request" ]; then
20-
# For PRs, compare against target branch
21-
git diff --name-only origin/$DRONE_TARGET_BRANCH...HEAD | grep -q "^github-metrics/" && echo "Changes detected" || (echo "No changes in github-metrics/, skipping" && exit 78)
22-
else
23-
# For pushes, compare against previous commit
24-
git diff --name-only $DRONE_COMMIT_BEFORE $DRONE_COMMIT_AFTER | grep -q "^github-metrics/" && echo "Changes detected" || (echo "No changes in github-metrics/, skipping" && exit 78)
25-
fi
26-
27-
- name: test
28-
image: node:20-alpine
29-
commands:
30-
- cd github-metrics
31-
- npm ci
32-
- node --version
33-
- npm --version
34-
- echo "Validating package.json and dependencies..."
35-
36-
---
37-
depends_on: ['github-metrics-test']
38-
kind: pipeline
39-
type: kubernetes
40-
name: github-metrics-build
41-
42-
trigger:
43-
branch:
44-
- main
45-
event:
46-
- push
47-
- tag
48-
49-
steps:
50-
# Builds and publishes Docker image for production
51-
- name: publish-production
52-
image: plugins/kaniko-ecr
53-
settings:
54-
create_repository: true
55-
registry: 795250896452.dkr.ecr.us-east-1.amazonaws.com
56-
repo: docs/github-metrics
57-
tags:
58-
- git-${DRONE_COMMIT_SHA:0:7}
59-
- latest
60-
access_key:
61-
from_secret: ecr_access_key
62-
secret_key:
63-
from_secret: ecr_secret_key
64-
context: github-metrics
65-
dockerfile: github-metrics/Dockerfile
66-
67-
---
68-
depends_on: ['github-metrics-build']
69-
kind: pipeline
70-
type: kubernetes
71-
name: github-metrics-deploy
72-
73-
trigger:
74-
branch:
75-
- main
76-
event:
77-
- push
78-
- tag
79-
80-
steps:
81-
# Deploys cronjob to production using Helm
82-
- name: deploy-production
83-
image: quay.io/mongodb/drone-helm:v3
84-
settings:
85-
chart: mongodb/cronjobs
86-
chart_version: 1.21.2
87-
add_repos: [mongodb=https://10gen.github.io/helm-charts]
88-
namespace: docs
89-
release: github-metrics
90-
values: image.tag=git-${DRONE_COMMIT_SHA:0:7},image.repository=795250896452.dkr.ecr.us-east-1.amazonaws.com/docs/github-metrics
91-
values_files: ['github-metrics/cronjobs.yml']
92-
api_server: https://api.prod.corp.mongodb.com
93-
kubernetes_token:
94-
from_secret: kubernetes_token
95-
13+
- name: check-changes
14+
image: alpine/git
15+
commands:
16+
- |
17+
# Check if any files in github-metrics/ directory changed
18+
git diff --name-only $DRONE_COMMIT_BEFORE $DRONE_COMMIT_AFTER | grep -q "^github-metrics/" && echo "Changes detected" || (echo "No changes in github-metrics/, skipping" && exit 78)
19+
20+
- name: test
21+
image: node:20-alpine
22+
commands:
23+
- cd github-metrics
24+
- npm ci
25+
- node --version
26+
- npm --version
27+
- echo "Validating package.json and dependencies..."
28+
29+
- name: publish
30+
image: plugins/kaniko-ecr
31+
settings:
32+
create_repository: true
33+
registry: 795250896452.dkr.ecr.us-east-1.amazonaws.com
34+
repo: docs/github-metrics
35+
tags:
36+
- git-${DRONE_COMMIT_SHA:0:7}
37+
- latest
38+
access_key:
39+
from_secret: ecr_access_key
40+
secret_key:
41+
from_secret: ecr_secret_key
42+
context: github-metrics
43+
dockerfile: github-metrics/Dockerfile
44+
45+
- name: deploy
46+
image: quay.io/mongodb/drone-helm:v3
47+
settings:
48+
chart: mongodb/cronjobs
49+
chart_version: 1.21.2
50+
add_repos: [ mongodb=https://10gen.github.io/helm-charts ]
51+
namespace: docs
52+
release: github-metrics
53+
values: image.tag=git-${DRONE_COMMIT_SHA:0:7},image.repository=795250896452.dkr.ecr.us-east-1.amazonaws.com/docs/github-metrics
54+
values_files: [ 'github-metrics/cronjobs.yml' ]
55+
api_server: https://api.prod.corp.mongodb.com
56+
kubernetes_token:
57+
from_secret: kubernetes_token

github-metrics/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ The cronjob requires two Kubernetes secrets to be created in the `docs` namespac
174174
-n docs
175175
```
176176

177-
> **Note**: These secrets should already exist in the production environment. Contact the DevOps team if you need to create or update them.
177+
> **Note**: These secrets should already exist in the production environment. Contact the DevDocs team if you need to create or update them.
178178
179179
### Deployment Process
180180

0 commit comments

Comments
 (0)