diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index aee09bf..eba6883 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,12 +2,20 @@ name: Build and Push container run-name: Build and Push container on: workflow_dispatch: - create: + #schedule: + # - cron: "0 10 * * *" push: + branches: + - 'main' + - 'master' + tags: + - 'v*' + pull_request: + branches: + - 'main' + - 'master' env: - VCS_REF: ${{ github.sha }} - VERSION: 0.0.1 - IMAGE: git.kvant.cloud/phoenix/docker_tpl + IMAGE: git.kvant.cloud/${{github.repository}} jobs: build_concierge_backend: runs-on: ubuntu-latest @@ -30,19 +38,37 @@ jobs: registry: git.kvant.cloud username: ${{ vars.PHOENIX_PACKAGE_WRITER_USERNAME }} password: ${{ secrets.PHOENIX_PACKAGE_WRITER_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ${{env.IMAGE}} + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: Build and push to gitea registry uses: docker/build-push-action@v6 with: - push: true - context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + context: . + provenance: mode=max + sbom: true build-args: | - BUILD_DATE=${{ steps.current_time.outputs.time }} - image: ${{ env.IMAGE }} + BUILD_DATE=${{ steps.current_time.outputs.time }} cache-from: | + type=registry,ref=${{ env.IMAGE }}:buildcache type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }} - type=registry,ref=${{ env.IMAGE }}:latest - cache-to: type=inline - tags: | - ${{ env.IMAGE }}:${{ github.ref_name }} - ${{ env.IMAGE }}:latest \ No newline at end of file + type=registry,ref=${{ env.IMAGE }}:main + cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max,image-manifest=true