From b6b3902db56dd1ed9ae7f1186d6c9e6b3f636ae6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 19 Dec 2022 18:08:06 +0100 Subject: [PATCH] Improve GitHub Actions workflows (based on #198) --- .../{codeql-analysis.yml => analysis.yml} | 2 +- .github/workflows/release.yml | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) rename .github/workflows/{codeql-analysis.yml => analysis.yml} (99%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/analysis.yml similarity index 99% rename from .github/workflows/codeql-analysis.yml rename to .github/workflows/analysis.yml index a3061ab..098fce2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/analysis.yml @@ -17,7 +17,7 @@ on: branches: [ master ] jobs: - analyze: + codeql-analyze: name: Analyze runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8f167e7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: "Build Docker image" + +on: + push: + tags: + - "v*" + +defaults: + run: + shell: bash + +jobs: + build-docker: + name: "🐳 Build and publish Docker image" + runs-on: ubuntu-latest + + steps: + - name: "Checkout repository" + uses: actions/checkout@v2 + + - name: "❓ Find the release semantic version" + id: semver + uses: Steffo99/actions-semver@v0.3.5 + with: + string: ${{ github.ref_name }} + + - name: "🔨 Setup Buildx" + uses: docker/setup-buildx-action@v1 + + - name: "🔑 Login to GitHub Containers" + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: "🔽 Find the lowercase name of the repository" + id: reponame + uses: ASzc/change-string-case-action@v5 + with: + string: ${{ github.repository }} + + - name: "🏗 Build and push the Docker image" + uses: docker/build-push-action@v3 + with: + tags: >- + ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.precedence }}, + ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.core }}, + ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.pair }}, + ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.major }}, + ghcr.io/${{ steps.reponame.outputs.lowercase }}:latest + push: true