diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml deleted file mode 100644 index 1bba046..0000000 --- a/.github/workflows/build-docker.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Build and push Docker image - -on: - workflow_dispatch: - push: - branches: - - main - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get repo name - id: get-repo - run: | - echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - - - name: Build and push - uses: docker/build-push-action@v5 - with: - build-args: | - VERSION=${{ github.sha }} - push: true - tags: ghcr.io/${{ steps.get-repo.outputs.repo }}:latest - platforms: amd64 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4c2e51c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,77 @@ +name: Build and push Docker image + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - '**.kt' + - '**.kts' + - 'gradle.properties' + - '.github/workflows/**' + - 'gradle/**' + - 'dockerfile' + pull_request: + branches: + - main + paths: + - '**.kt' + - '**.kts' + - 'gradle.properties' + - '.github/workflows/**' + - 'gradle/**' + - 'dockerfile' + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: ${{ vars.JVM_DISTRIBUTION }} + java-version: ${{ vars.JVM_VERSION }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Gradle Wrapper Validation + uses: gradle/actions/wrapper-validation@v3 + + - name: Check + run: ./gradlew check + + build: + name: Build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + needs: check + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get repo name + id: get-repo + run: | + echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v5 + with: + build-args: | + VERSION=${{ github.sha }} + push: true + tags: ghcr.io/${{ steps.get-repo.outputs.repo }}:latest + platforms: amd64 \ No newline at end of file