Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve automatisms #90

Merged
merged 4 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"packageRules": [
{
"matchPackagePatterns": [
"*"
],
"matchUpdateTypes": [
"minor",
"patch"
],
"automerge": true,
"labels": [
"dependencies"
]
}
],
"extends": [
"config:base",
":dependencyDashboard"
"config:base"
]
}
22 changes: 13 additions & 9 deletions .github/workflows/gradle.yml → .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
name: Gradle build CI
name: Code coverage CI

on:
push:
branches: [ master ]
workflow_dispatch:
pull_request:
branches: [ master ]
push:
branches:
- master

jobs:
build:

coverage:
name: Build project and upload coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout code changes
uses: actions/checkout@v4

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

- name: Build project with Gradle
run: chmod +x gradlew && ./gradlew build --no-daemon

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./build/reports/jacoco/test/
Expand Down
68 changes: 53 additions & 15 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
name: Docker Image CI

on:
workflow_dispatch:
pull_request:
push:
branches: [ master ]
branches:
- master

jobs:

build:

docker:
name: Build and upload Docker image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build the Docker image
run: docker build . --file Dockerfile --tag rob93c/christmas-greeter:latest

- name: Perform Docker login
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Upload the latest Docker image
run: docker push rob93c/christmas-greeter:latest
- name: Checkout code changes
uses: actions/checkout@v4

- name: Prepare Docker
uses: docker/setup-buildx-action@v3

- name: Access Docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
rob93c/christmas-greeter
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr

- name: Set Docker tags
id: docker-tags
run: |
cleaned_tags=${{ steps.metadata.outputs.tags }}
if [[ " ${{ steps.metadata.outputs.tags }} " =~ "christmas-greeter:latest" ]]; then
cleaned_tags=("***/christmas-greeter:latest")
fi
echo "cleaned_tags=${cleaned_tags}" >> "$GITHUB_OUTPUT"

- name: Upload Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.docker-tags.outputs.cleaned_tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Delete Docker tag
if: github.event.pull_request.merged
run: |
tag_to_delete="pr-${{github.event.issue.number}}"
docker rmi rob93c/christmas-greeter:$tag_to_delete
echo "The tag $tag_to_delete has been deleted"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Java version](https://badgen.net/badge/Java/Java%2019/orange?icon=https://raw.githubusercontent.com/rob93c/BadgenIcons/master/icons/java-logo.svg&labelColor=292f35&label)](https://github.com/rob93c/ChristmasGreeter/search?l=java)
[![Codacy Badge](https://badgen.net/codacy/grade/361904c6ec0d4a1490aa7d5593f8e26a?icon=https://raw.githubusercontent.com/rob93c/BadgenIcons/master/icons/codacy-logo.svg&labelColor=292f35&label=Code%20quality)](https://www.codacy.com/gh/rob93c/ChristmasGreeter/dashboard)
[![Codecov](https://badgen.net/badge/codecov/coverage/3bbe58?icon=https://raw.githubusercontent.com/rob93c/BadgenIcons/master/icons/codecov-logo.svg&labelColor=292f35&label=codecov)](https://app.codecov.io/gh/rob93c/ChristmasGreeter)
[![Gradle build CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/gradle.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/gradle.yml)
[![Code coverage CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/gradle.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/coverage.yml)
[![Docker Image CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/docker-image.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/docker-image.yml)
[![Code Analysis CI](https://github.com/rob93c/ChristmasGreeter/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/rob93c/ChristmasGreeter/actions/workflows/codeql-analysis.yml)
[![Docker Image](https://badgen.net/badge/docker/Docker?icon=docker&labelColor=292f35&label)](https://hub.docker.com/r/rob93c/christmas-greeter)
Expand All @@ -20,7 +20,7 @@ The project itself is built with **Java 19**, and it comes with the following de

* `Apache Commons 3`
* `JUnit 5`
* `Mockito 4`
* `Mockito 5`
* `Apache log4j 2`

## How to set up the project
Expand Down