Updated instructions and demo compose file #6
Workflow file for this run
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
name: Build and Publish to GHCR | |
on: | |
push: | |
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 | |
- name: Extract tag name | |
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
with: | |
args: -Dsonar.projectVersion=${{ env.VERSION }} | |
- 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: 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 |