From f321e7b0cdbbe9a82cac9f4db8477df5e5a7d551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicklas=20K=C3=B6rtge?= Date: Wed, 18 Sep 2024 10:48:01 +0200 Subject: [PATCH] add docker image build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicklas Körtge --- .github/workflows/backend.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 76a2812ab..517bc7e4c 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -15,6 +15,10 @@ on: branches: [ "main" ] workflow_dispatch: +env: + REGISTRY: "ghcr.io" + IMAGE_NAME: "cbomkit" + jobs: build: runs-on: ubuntu-latest @@ -56,6 +60,29 @@ jobs: run: mvn clean package env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Log in to the Container registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph uses: advanced-security/maven-dependency-submission-action@v4 \ No newline at end of file