Skip to content

Commit

Permalink
Updated build file to include GHCR publish
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinscham committed Sep 8, 2023
1 parent 005d9ca commit 6510d8c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,57 @@
name: Build
name: Build and Publish to GHCR

on:
push:
branches:
- main
tags:
- 'v*.*.*'
- 'v*.*.*-*'

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions: read-all

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- name: Extract tag name and check if pre-release
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
if [[ "${GITHUB_REF#refs/tags/}" == *-* ]]; then
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "PRERELEASE=false" >> $GITHUB_ENV
fi
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}

- name: Extract tag name
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Build and push version-tagged Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ env.VERSION }}

- name: Build and push latest Docker image
if: env.PRERELEASE == 'false'
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest

0 comments on commit 6510d8c

Please sign in to comment.