diff --git a/.github/workflows/docker-delete-tag-on-merge.yml b/.github/workflows/docker-delete-tag-on-merge.yml index 49b2e7d..80822b4 100644 --- a/.github/workflows/docker-delete-tag-on-merge.yml +++ b/.github/workflows/docker-delete-tag-on-merge.yml @@ -7,16 +7,22 @@ on: jobs: delete-docker-tag: - if: startsWith(github.event.pull_request.head.ref, 'fix/') + if: startsWith(github.event.pull_request.head.ref, 'fix/') || startsWith(github.event.pull_request.head.ref, 'release/') runs-on: ubuntu-latest permissions: packages: write steps: - - name: Extract merged branch name + - name: Extract merged branch name and tag id: extract_branch run: | BRANCH="${{ github.event.pull_request.head.ref }}" - TAG=${BRANCH#fix/} + if [[ "$BRANCH" == fix/* ]]; then + TAG=${BRANCH#fix/} + elif [[ "$BRANCH" == release/* ]]; then + TAG="${BRANCH#release/}-preview" + else + TAG="" + fi echo "tag=$TAG" >> $GITHUB_OUTPUT shell: bash diff --git a/.github/workflows/docker-preview.yml b/.github/workflows/docker-preview.yml new file mode 100644 index 0000000..61bedf2 --- /dev/null +++ b/.github/workflows/docker-preview.yml @@ -0,0 +1,45 @@ +name: Build and Push Docker Image (release/*) + +on: + push: + branches: + - 'release/*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Set up JDK 21 + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + + - name: Run production build + env: + GAMEYFIN_KEYSTORE_PASSWORD: ${{ secrets.GAMEYFIN_KEYSTORE_PASSWORD }} + run: ./gradlew clean build -Pvaadin.productionMode=true + + - name: Extract tag from branch name + id: extract_tag + run: | + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + TAG="${BRANCH_NAME#release/}-preview" + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Build and push Docker image + uses: ./.github/actions/docker-build-push + with: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} + ghcr_username: ${{ github.actor }} + ghcr_token: ${{ secrets.GITHUB_TOKEN }} + context: . + dockerfile: docker/Dockerfile + platforms: linux/arm64/v8,linux/amd64 + tags: grimsi/gameyfin:${{ steps.extract_tag.outputs.tag }},ghcr.io/gameyfin/gameyfin:${{ steps.extract_tag.outputs.tag }}