Skip to content

Commit

Permalink
Publish through github actions as automatic dockerhub automatic build… (
Browse files Browse the repository at this point in the history
#6)

* Publish through github actions as automatic dockerhub automatic builds now are premium.
  • Loading branch information
gguridi authored Nov 18, 2022
1 parent 9f56ea6 commit bfcb8ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: push
on: [push, release]

jobs:
kafka-test:
Expand All @@ -9,6 +9,10 @@ jobs:
matrix:
scala_version: [2.12, 2.13]
kafka_version: [2.8.2, 3.0.2, 3.1.2, 3.2.3, 3.3.1]
env:
KAFKA_IMAGE: kafka-test
SCALA_VERSION: ${{ matrix.scala_version }}
KAFKA_VERSION: ${{ matrix.kafka_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -17,13 +21,37 @@ jobs:
- name: install dependencies
run: yarn install
- name: build kafka images
env:
SCALA_VERSION: ${{ matrix.scala_version }}
KAFKA_VERSION: ${{ matrix.kafka_version }}
run: yarn run build
- name: run kafka image
run: |
yarn run docker-run
sleep 10
- name: run tests
run: yarn test

publish:
runs-on: ubuntu-latest
needs: kafka-test
if: github.event_name == 'release'
strategy:
matrix:
scala_version: [2.12, 2.13]
kafka_version: [2.8.2, 3.0.2, 3.1.2, 3.2.3, 3.3.1]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: install dependencies
run: yarn install
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: publish kafka images
env:
KAFKA_IMAGE: "gguridi/kafka:${{ matrix.scala_version }}-${{ matrix.kafka_version }}"
SCALA_VERSION: ${{ matrix.scala_version }}
KAFKA_VERSION: ${{ matrix.kafka_version }}
run: yarn run publish
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"description": "Docker images with Kafka to be used in testing/development environment",
"scripts": {
"start": "mockserver -p 80 -q -m /opt/api",
"build": "docker build -t kafka-server --build-arg SCALA_VERSION=$SCALA_VERSION --build-arg KAFKA_VERSION=$KAFKA_VERSION .",
"docker-run": "docker run --name kafka-local -d -p 2181:2181 -p 9092:9092 -e KAFKA__ADVERTISED_HOST_NAME=localhost -e KAFKA__ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 kafka-server",
"build": "docker build -t $KAFKA_IMAGE --build-arg SCALA_VERSION=$SCALA_VERSION --build-arg KAFKA_VERSION=$KAFKA_VERSION .",
"publish": "yarn run build && docker push $KAFKA_IMAGE",
"docker-run": "docker run --name kafka-local -d -p 2181:2181 -p 9092:9092 -e KAFKA__ADVERTISED_HOST_NAME=localhost -e KAFKA__ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 $KAFKA_IMAGE",
"docker-stop": "docker rm -f kafka-local || true",
"test": "node ./node_modules/jest/bin/jest.js --forceExit --detectOpenHandles"
},
Expand Down

0 comments on commit bfcb8ac

Please sign in to comment.