-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated build file to include GHCR publish
- Loading branch information
1 parent
005d9ca
commit 6510d8c
Showing
1 changed file
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |