ClaptrapBot/.github/workflows/build.yml
2022-05-15 16:40:00 +02:00

69 lines
1.6 KiB
YAML

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Upload Jar File
uses: actions/upload-artifact@v2-preview
with:
name: claptrap_jar
path: build/libs/
build-docker:
runs-on: ubuntu-latest
needs:
- build-gradle
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v1.0.0
with:
# Artifact name
name: claptrap_jar
# Destination path
path: build/libs/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to ghcr.io
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push Docker
uses: docker/build-push-action@v2
with:
push: true
context: .
tags: ghcr.io/sebclem/claptrapbot:latest
file: ./Dockerfile