Skip to content

Commit

Permalink
switch to reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSebastian committed Apr 7, 2024
1 parent a0ef003 commit 9fc9dd7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 75 deletions.
65 changes: 16 additions & 49 deletions .github/workflows/create-ghcr-image-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ env:
REGISTRY: ghcr.io

jobs:
publish-ghcr-image:
permissions:
packages: write
extract-service:
runs-on: ubuntu-latest
outputs:
service: ${{ steps.getTagNameParts.outputs.service }}
version: ${{ steps.getTagNameParts.outputs.version }}
tag: ${{ steps.getTagNameParts.outputs.tag }}
steps:
- uses: olegtarasov/[email protected]
id: getTagNameParts
Expand All @@ -32,49 +34,14 @@ jobs:
echo "Version: $version"
echo "tagFromAction: $tagFromAction"
- name: Check out Git repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
env:
service: ${{ steps.getTagNameParts.outputs.service }}
with:
cache: 'maven'
cache-dependency-path: ${{ steps.getTagNameParts.outputs.service }}/pom.xml
java-version: '17'
distribution: 'temurin'

- name: build jar without tests
run: mvn -B -ntp -DskipTests package -f ${{ steps.getTagNameParts.outputs.service }}/pom.xml

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}-${{ steps.getTagNameParts.outputs.service }}
# tags:
# - Major
# - Major.Minor
# - full semver: 1.2.3
# - latest
tags: |
type=match,pattern=(${{ steps.getTagNameParts.outputs.service }})/v(\d).\d.\d,group=2
type=match,pattern=(${{ steps.getTagNameParts.outputs.service }})/v(\d.\d).\d,group=2
type=match,pattern=(${{ steps.getTagNameParts.outputs.service }})/v(.*),group=2
type=raw,value=latest
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ./${{ steps.getTagNameParts.outputs.service }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish-ghcr-image:
permissions:
packages: write
needs:
- extract-service
runs-on: ubuntu-latest
uses:
./.github/workflows/callable-create-ghcr-image-from-tag.yml
with:
tag: ${{ needs.extract-service.outputs.service }}/v${{ needs.extract-service.outputs.version }}
service: ${{ needs.extract-service.outputs.service }}
42 changes: 16 additions & 26 deletions .github/workflows/create-release-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ env:
REGISTRY: ghcr.io

jobs:
publish-ghcr-image:
permissions:
contents: write
extract-service:
runs-on: ubuntu-latest
outputs:
service: ${{ steps.getTagNameParts.outputs.service }}
version: ${{ steps.getTagNameParts.outputs.version }}
tag: ${{ steps.getTagNameParts.outputs.tag }}
steps:
- uses: olegtarasov/[email protected]
id: getTagNameParts
Expand All @@ -32,26 +34,14 @@ jobs:
echo "Version: $version"
echo "tagFromAction: $tagFromAction"
- name: Check out Git repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
cache: 'maven'
cache-dependency-path: '${{ steps.getTagNameParts.outputs.service }}/pom.xml'
java-version: '17'
distribution: 'temurin'

- name: build jar without tests
run: mvn -B -ntp -DskipTests package -f ${{ steps.getTagNameParts.outputs.service }}/pom.xml

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
${{ steps.getTagNameParts.outputs.service }}/target/*.jar
draft: false
prerelease: false
generate_release_notes: false
publish-ghcr-image:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- extract-service
uses:
./.github/workflows/callable-create-release-from-tag.yml
with:
tag: ${{ needs.extract-service.outputs.service }}/v${{ needs.extract-service.outputs.version }}
service: ${{ needs.extract-service.outputs.service }}

0 comments on commit 9fc9dd7

Please sign in to comment.