Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
realRobotix authored Dec 26, 2022
1 parent 4b55e7e commit 7a6e111
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
workflow_dispatch:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3

- name: Get branch name
id: get_branch
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT

- name: Get latest commit hash
id: get_hash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Get MC version
uses: christian-draeger/read-properties@908f99d3334be3802ec7cb528395a69d19914e7b
id: get_mc_version
with:
path: gradle.properties
properties: mc_version

- name: Send building message to discord
if: github.event_name == 'push'
uses: realRobotix/action-discord-notifier@release-master
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
message-title: Building mod from branch ${{ steps.get_branch.outputs.branch }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build jar
uses: gradle/gradle-build-action@v2
with:
arguments: build

- name: Send built file to discord
if: github.event_name == 'push'
uses: sinshutu/upload-to-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: ./build/libs/*.*

- name: Archive Artifacts
uses: actions/upload-artifact@v3
with:
name: betsyross-${{ steps.get_mc_version.outputs.mc_version }}-nightly-${{ steps.get_hash.outputs.sha_short }}
path: build/libs/

0 comments on commit 7a6e111

Please sign in to comment.