diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3ac846..f3f88b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: branches: ["main"] + tags: ["v*"] pull_request: jobs: @@ -29,7 +30,7 @@ jobs: runs-on: ubuntu-latest needs: - test - if: ${{ github.repository_owner == 'sbidoul' && github.ref == 'refs/heads/main' }} + if: ${{ github.repository_owner == 'sbidoul' && github.event_name == 'push' }} steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -39,13 +40,21 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} - name: Build image uses: docker/build-push-action@v6 with: - tags: | - ghcr.io/${{ github.repository }}:latest - labels: | - org.opencontainers.image.source=${{ github.event.repository.html_url }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:latest cache-to: type=inline push: true