Skip to content

Commit

Permalink
update build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zt64 committed May 26, 2024
1 parent 6a5dac5 commit fb5e5c5
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 36 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/build-docker.yml

This file was deleted.

77 changes: 77 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fb5e5c5

Please sign in to comment.