Skip to content

Commit fd71624

Browse files
authored
Merge pull request #173 from ovotech/BPCPOD-11801-github-actions-pipeline
BPCPOD-11801 Migrate pipeline to GitHub actions
2 parents 393f226 + 6a016df commit fd71624

5 files changed

Lines changed: 235 additions & 84 deletions

File tree

.circleci/config.yml

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
version: 2
2-
3-
npmrc-git: &npmrc-git
4-
run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > ~/.npmrc
5-
6-
restore-cache: &restore-cache
7-
restore_cache:
8-
keys:
9-
- v1-{{ checksum "yarn.lock" }}
10-
11-
save-cache: &save-cache
12-
save_cache:
13-
key: v1-{{ checksum "yarn.lock" }}
14-
paths:
15-
- ~/.cache
16-
17-
jobs:
18-
test:
19-
docker:
20-
- image: circleci/node:12
21-
- image: confluentinc/cp-zookeeper:5.0.1
22-
environment:
23-
ZOOKEEPER_CLIENT_PORT: 2181
24-
ZOOKEEPER_TICK_TIME: 2000
25-
- image: confluentinc/cp-kafka:5.0.1
26-
environment:
27-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
28-
KAFKA_ZOOKEEPER_CONNECT: 'localhost:2181'
29-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
30-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_HOST://localhost:29092
31-
- image: confluentinc/cp-schema-registry:5.0.1
32-
environment:
33-
SCHEMA_REGISTRY_HOST_NAME: localhost
34-
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'localhost:2181'
35-
- image: circleci/postgres:10-alpine
36-
environment:
37-
POSTGRES_PASSWORD: dev-pass
38-
steps:
39-
- checkout
40-
- *restore-cache
41-
- run: yarn config set yarn-offline-mirror ~/.cache/yarn
42-
- run: yarn
43-
- *save-cache
44-
- run: yarn build
45-
- run: .circleci/wait-for-server.sh
46-
- run: yarn test
47-
48-
publish:
49-
docker:
50-
- image: circleci/node:12
51-
steps:
52-
- checkout
53-
- *restore-cache
54-
- *npmrc-git
55-
- run: yarn config set yarn-offline-mirror ~/.cache/yarn
56-
- run: yarn --frozen-lockfile
57-
- run: yarn build
58-
- run: git config user.email "ovotech-ci@ovoenergy.com"
59-
- run: git config user.name "Ovotech CI"
60-
- run: yarn lerna publish from-package --yes --registry https://npm.pkg.github.com
61-
62-
workflows:
63-
version: 2
64-
test:
65-
jobs:
66-
- test:
67-
context: boost-btt
68-
filters:
69-
branches:
70-
ignore: master
71-
deploy:
72-
jobs:
73-
- test:
74-
context: boost-btt
75-
filters:
76-
branches:
77-
only: master
78-
- publish:
79-
context: boost-btt
80-
requires:
81-
- test
1+
# version: 2
2+
#
3+
# npmrc-git: &npmrc-git
4+
# run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > ~/.npmrc
5+
#
6+
# restore-cache: &restore-cache
7+
# restore_cache:
8+
# keys:
9+
# - v1-{{ checksum "yarn.lock" }}
10+
#
11+
# save-cache: &save-cache
12+
# save_cache:
13+
# key: v1-{{ checksum "yarn.lock" }}
14+
# paths:
15+
# - ~/.cache
16+
#
17+
# jobs:
18+
# test:
19+
# docker:
20+
# - image: circleci/node:12
21+
# - image: confluentinc/cp-zookeeper:5.0.1
22+
# environment:
23+
# ZOOKEEPER_CLIENT_PORT: 2181
24+
# ZOOKEEPER_TICK_TIME: 2000
25+
# - image: confluentinc/cp-kafka:5.0.1
26+
# environment:
27+
# KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
28+
# KAFKA_ZOOKEEPER_CONNECT: 'localhost:2181'
29+
# KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
30+
# KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_HOST://localhost:29092
31+
# - image: confluentinc/cp-schema-registry:5.0.1
32+
# environment:
33+
# SCHEMA_REGISTRY_HOST_NAME: localhost
34+
# SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'localhost:2181'
35+
# - image: circleci/postgres:10-alpine
36+
# environment:
37+
# POSTGRES_PASSWORD: dev-pass
38+
# steps:
39+
# - checkout
40+
# - *restore-cache
41+
# - run: yarn config set yarn-offline-mirror ~/.cache/yarn
42+
# - run: yarn
43+
# - *save-cache
44+
# - run: yarn build
45+
# - run: .circleci/wait-for-server.sh
46+
# - run: yarn test
47+
#
48+
# publish:
49+
# docker:
50+
# - image: circleci/node:12
51+
# steps:
52+
# - checkout
53+
# - *restore-cache
54+
# - *npmrc-git
55+
# - run: yarn config set yarn-offline-mirror ~/.cache/yarn
56+
# - run: yarn --frozen-lockfile
57+
# - run: yarn build
58+
# - run: git config user.email "ovotech-ci@ovoenergy.com"
59+
# - run: git config user.name "Ovotech CI"
60+
# - run: yarn lerna publish from-package --yes --registry https://npm.pkg.github.com
61+
#
62+
# workflows:
63+
# version: 2
64+
# test:
65+
# jobs:
66+
# - test:
67+
# context: boost-btt
68+
# filters:
69+
# branches:
70+
# ignore: master
71+
# deploy:
72+
# jobs:
73+
# - test:
74+
# context: boost-btt
75+
# filters:
76+
# branches:
77+
# only: master
78+
# - publish:
79+
# context: boost-btt
80+
# requires:
81+
# - test

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
services:
12+
zookeeper:
13+
image: confluentinc/cp-zookeeper:5.0.1
14+
env:
15+
ZOOKEEPER_CLIENT_PORT: 2181
16+
ZOOKEEPER_TICK_TIME: 2000
17+
ports:
18+
- 2181:2181
19+
kafka:
20+
image: confluentinc/cp-kafka:5.0.1
21+
env:
22+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
23+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
24+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
25+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
26+
ports:
27+
- 9092:9092
28+
- 29092:29092
29+
schema-registry:
30+
image: confluentinc/cp-schema-registry:5.0.1
31+
env:
32+
SCHEMA_REGISTRY_HOST_NAME: schema-registry
33+
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: zookeeper:2181
34+
ports:
35+
- 8081:8081
36+
postgres:
37+
image: circleci/postgres:10-alpine
38+
env:
39+
POSTGRES_PASSWORD: dev-pass
40+
ports:
41+
- 5432:5432
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v3
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: '12'
51+
52+
- name: Cache dependencies
53+
uses: actions/cache@v3
54+
with:
55+
path: ~/.cache/yarn
56+
key: v1-${{ hashFiles('**/yarn.lock') }}
57+
restore-keys: |
58+
v1-
59+
60+
- name: Configure yarn
61+
run: yarn config set yarn-offline-mirror ~/.cache/yarn
62+
63+
- name: Install dependencies
64+
run: yarn install
65+
66+
- name: Build
67+
run: yarn build
68+
69+
- name: Wait for server
70+
run: .github/workflows/wait-for-server.sh
71+
72+
- name: Test
73+
run: yarn test
74+
75+
prepare-publish:
76+
needs: test
77+
if: github.ref == 'refs/heads/master'
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v3
82+
83+
- name: Setup Node.js
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: '12'
87+
88+
- name: Cache dependencies
89+
uses: actions/cache@v3
90+
with:
91+
path: ~/.cache/yarn
92+
key: v1-${{ hashFiles('**/yarn.lock') }}
93+
restore-keys: |
94+
v1-
95+
96+
- name: Configure yarn
97+
run: yarn config set yarn-offline-mirror ~/.cache/yarn
98+
99+
- name: Install dependencies
100+
run: yarn install --frozen-lockfile
101+
102+
- name: Setup npmrc
103+
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
104+
105+
- name: List changed packages
106+
run: yarn lerna exec --concurrency 1 'if [ "$(npm view $LERNA_PACKAGE_NAME version --registry=https://npm.pkg.github.com/ 2>/dev/null || echo "0.0.0")" != "$(node -p "require(\"./package.json\").version")" ]; then echo "Will publish $LERNA_PACKAGE_NAME@$(node -p "require(\"./package.json\").version")"; fi'
107+
108+
publish:
109+
needs: prepare-publish
110+
if: github.ref == 'refs/heads/master'
111+
runs-on: ubuntu-latest
112+
environment:
113+
name: github-npm-registry
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v3
117+
118+
- name: Setup Node.js
119+
uses: actions/setup-node@v3
120+
with:
121+
node-version: '12'
122+
123+
- name: Setup npmrc
124+
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
125+
126+
- name: Cache dependencies
127+
uses: actions/cache@v3
128+
with:
129+
path: ~/.cache/yarn
130+
key: v1-${{ hashFiles('**/yarn.lock') }}
131+
restore-keys: |
132+
v1-
133+
134+
- name: Configure yarn
135+
run: yarn config set yarn-offline-mirror ~/.cache/yarn
136+
137+
- name: Install dependencies
138+
run: yarn install --frozen-lockfile
139+
140+
- name: Build
141+
run: yarn build
142+
143+
- name: Configure Git
144+
run: |
145+
git config user.email "ovotech-ci@ovoenergy.com"
146+
git config user.name "Ovotech CI"
147+
148+
- name: Publish
149+
run: yarn lerna publish from-package --yes --registry https://npm.pkg.github.com
150+
env:
151+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ yarn lint
8383

8484
## Deployment
8585

86-
Deployment is performed by lerna automatically on merge / push to master. You'll need to bump the package version numbers yourself. Only updated packages with newer versions will be pushed to the npm registry.
86+
1. MANUALLY bump the package version along with your changes
87+
2. On merge to master lerna will pick up on the changes and output what will be published in the GitHub actions job `prepare-publish`
88+
3. MANUALLY approve deployment for the GitHub actions job `publish`
8789

8890
## Built With
8991

0 commit comments

Comments
 (0)