name: Publish server Docker image on: push: branches: ["main"] tags: ["*"] pull_request: branches: ["main"] jobs: publish-docker: runs-on: ubuntu-docker steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Extract registry hostname id: registry run: echo "host=$(echo '${{ github.server_url }}' | sed 's|https\?://||')" >> "$GITHUB_OUTPUT" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log into container registry if: github.ref_type == 'tag' uses: docker/login-action@v3 with: registry: ${{ steps.registry.outputs.host }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ steps.registry.outputs.host }}/${{ github.repository }} - name: Build and push Docker image id: build-and-push uses: docker/build-push-action@v5 with: context: sync-server platforms: linux/amd64,linux/arm64 push: ${{ github.ref_type == 'tag' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ steps.registry.outputs.host }}/${{ github.repository }}:buildcache cache-to: type=registry,ref=${{ steps.registry.outputs.host }}/${{ github.repository }}:buildcache,mode=max