Skip to content
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
44 changes: 10 additions & 34 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
name: CI/CD Pipeline

# Tagging policy:
# - push to main -> Docker Hub image tagged :dev (this workflow)
# - GitHub release -> Docker Hub images tagged :main and :vA.B.C (release-please.yml)
# Releases are created by release-please with the default GITHUB_TOKEN, which
# does NOT trigger this workflow, so the release images are built there.
on:
push:
branches: [ main, dev ]
tags: [ 'v*' ]
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]

env:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
# Docker Hub image (public): mobiera/<repo>
IMAGE: "mobiera/${{ github.event.repository.name }}"
# Default tag is main, will be overridden based on branch/tag
IMAGE_TAG: "main"
# main pushes publish the :dev image.
IMAGE_TAG: "dev"

jobs:
build:
Expand All @@ -27,22 +29,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set image tag
run: |
# If it's not main branch, use branch name as tag
if [[ "${{ github.ref_name }}" != "main" && "${{ github.ref_type }}" == "branch" ]]; then
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
# If it's a tag (not empty), use tag name without 'v' prefix
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "IMAGE_TAG=$(echo "${{ github.ref_name }}" | sed 's/v//')" >> $GITHUB_ENV
fi

- name: Log tag info
run: |
echo "Tag: ${{ github.ref_name }}"
echo "Branch: ${{ github.ref_name }}"
echo "Image Tag: ${{ env.IMAGE_TAG }}"

- name: Create Maven settings directory
run: |
export MVN_SETTINGS_DIR="/builds/current/${{ github.event.repository.name }}/${{ env.IMAGE_TAG }}"
Expand Down Expand Up @@ -80,22 +66,12 @@ jobs:
docker-package:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.event_name == 'release'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

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

- name: Set image tag
run: |
# If it's not main branch, use branch name as tag
if [[ "${{ github.ref_name }}" != "main" && "${{ github.ref_type }}" == "branch" ]]; then
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
# If it's a tag (not empty), use tag name without 'v' prefix
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "IMAGE_TAG=$(echo "${{ github.ref_name }}" | sed 's/v//')" >> $GITHUB_ENV
fi

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -167,7 +143,7 @@ jobs:
security-scan:
runs-on: ubuntu-latest
needs: docker-package
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- name: Checkout code
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ jobs:

- name: Build and push container image
run: |
VERSION="${TAG_NAME#v}"
echo "Building ${IMAGE}:${VERSION} from tag ${TAG_NAME}"
docker build -f src/main/docker/Dockerfile.jvm -t "${IMAGE}:${VERSION}" .
docker push "${IMAGE}:${VERSION}"
echo "Building ${IMAGE}:main and ${IMAGE}:${TAG_NAME} from tag ${TAG_NAME}"
docker build -f src/main/docker/Dockerfile.jvm \
-t "${IMAGE}:main" \
-t "${IMAGE}:${TAG_NAME}" .
docker push "${IMAGE}:main"
docker push "${IMAGE}:${TAG_NAME}"
Loading