name: deploy-docker-image env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} on: push: branches: - "master" jobs: docker-build-deploy: runs-on: ubuntu-latest permissions: contents: read packages: write attestations: write id-token: write steps: - name: Check Repository id: repo_check run: | if [ "${{ github.repository }}" != "Pumpkin-MC/Pumpkin" ]; then echo "Not the target repository. Skipping deployment." echo "should_deploy=false" >> $GITHUB_OUTPUT else echo "Target repository confirmed. Proceeding with deployment." echo "should_deploy=true" >> $GITHUB_OUTPUT fi - name: Checkout if: steps.repo_check.outputs.should_deploy == 'true' uses: actions/checkout@v5 - name: Login to GitHub CR if: steps.repo_check.outputs.should_deploy == 'true' uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Versions if: steps.repo_check.outputs.should_deploy == 'true' id: versions run: | VERSION=$(awk -F '"' '/^version/ {print $2}' Cargo.toml) echo "PUMPKIN_VERSION=$(echo $VERSION | cut -d '+' -f 1)" >> $GITHUB_ENV echo "MC_VERSION=$(echo $VERSION | cut -d '+' -f 2)" >> $GITHUB_ENV - name: Extract Metadata if: steps.repo_check.outputs.should_deploy == 'true' id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=raw,value=latest type=sha type=raw,value=mc${{ env.MC_VERSION }} type=raw,value=${{ env.PUMPKIN_VERSION }} type=raw,value=mc${{ env.MC_VERSION }}-${{ env.PUMPKIN_VERSION }} - name: Docker Buildx if: steps.repo_check.outputs.should_deploy == 'true' uses: docker/setup-buildx-action@v3 - name: Build and Push if: steps.repo_check.outputs.should_deploy == 'true' uses: docker/build-push-action@v6 with: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }}