Skip to content

Commit

Permalink
Move docker build to github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed Sep 11, 2023
1 parent d510604 commit 5a611b7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 18 deletions.
18 changes: 0 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ aliases:
echo 'export CIRCLE_SHA1="$CIRCLE_SHA1"' >> $BASH_ENV
echo 'export CIRCLE_PROJECT_REPONAME="$CIRCLE_PROJECT_REPONAME"' >> $BASH_ENV
.circleci/trigger_build_v2.sh "entur/lamassu-deployment-config.git" "master" "$(git log -1 --pretty=%B)"
- &docker-build
name: Docker build
command: |
DOCKER_BUILDKIT=1 docker build .
jobs:
test:
Expand Down Expand Up @@ -108,17 +104,6 @@ jobs:
# Cannot use -o because of snapshot dependencies.
- run: mvn deploy -s .circleci/settings.xml -P prettierSkip -DskipTests
- run: *post_build
docker-build:
docker:
- image: cimg/openjdk:17.0.8
auth:
username: $DOCKERHUB_LOGIN
password: $DOCKERHUB_PASSWORD
steps:
- setup_remote_docker:
version: 20.10.24
- checkout
- run: *docker-build

workflows:
version: 2.1
Expand All @@ -136,6 +121,3 @@ workflows:
- master
requires:
- test-release
- docker-build:
name: docker-build
context: global
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI Build

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
tests:
runs-on: ubuntu-latest
env:
TZ: Europe/Oslo
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven

- name: Run tests
run: |
sudo timedatectl set-timezone "Europe/Oslo"
mvn --batch-mode test
image:
# only build and push the image when it's a commit to master in Entur's repository
if: github.repository_owner == 'entur' && github.event_name == 'push'

This comment has been minimized.

Copy link
@derhuerst

derhuerst Sep 11, 2023

Contributor

@testower FYI: This does not check if the push has happened on master, instead it will build & publish every branch as :latest!

This comment has been minimized.

Copy link
@derhuerst

derhuerst Sep 11, 2023

Contributor

This if: effectively disables the CI Docker build for PRs. In #214, I had configured it so that it merely enables/disables the push based on repo, branch name and push/PR.

https://github.com/entur/lamassu/pull/214/files#diff-9136d7ee194d90376becf626f92179e6d99617d858ce125f6f73ca09fa410840R34

runs-on: ubuntu-latest
needs: [ tests ]
env:
CONTAINER_REPO: docker.io/entur/lamassu
CONTAINER_REGISTRY_USER: ${{ secrets.DOCKERHUB_LOGIN }}
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven

- name: Build container image with Jib, push to Github Container Repo
run: |
image_date=`date +%Y-%m-%dT%H-%M`
mvn --batch-mode compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_date

0 comments on commit 5a611b7

Please sign in to comment.