diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml new file mode 100644 index 0000000..581b82a --- /dev/null +++ b/.gitea/workflows/docker.yaml @@ -0,0 +1,46 @@ +name: Build and push docker images + +on: + push: + tags: ["v*"] + branches: [ main ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Gitea Container Registry + uses: docker/login-action@v2 + with: + registry: git.yongyuancv.cn + username: ${{ gitea.repository_owner }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Calculate docker image tag + id: set-tag + uses: docker/metadata-action@master + with: + images: | + git.yongyuancv.cn/${{ gitea.repository }} + git.yongyuancv.cn/heimoshuiyu/${{ gitea.event.repository.name }} + flavor: | + latest=false + tags: | + type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' }} + type=sha,prefix=,format=long + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + + - name: Build and push all platforms + uses: docker/build-push-action@v4 + with: + push: true + labels: "gitsha1=${{ gitea.sha }}" + tags: "${{ steps.set-tag.outputs.tags }}" + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=git.yongyuancv.cn/${{ gitea.repository }}:buildcache + cache-to: type=registry,ref=git.yongyuancv.cn/${{ gitea.repository }}:buildcache,mode=max