Merge pull request #52 from Ender-Cube/discord-loginmsg #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Build with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Execute Gradle build | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Endercube | |
path: build/libs/endercube-*.*.*.jar | |
docker-push: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Set ${{ steps.version.outputs.VERSION }} | |
- name: Retrieve version | |
run: | | |
echo "VERSION=$(./gradlew properties | grep -Po '(?<=version: ).*')" >> $GITHUB_OUTPUT | |
id: version | |
- uses: actions/download-artifact@v4 | |
with: | |
name: Endercube | |
path: build/libs | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build, and push to Docker Hub | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/endercube:latest, ${{ secrets.DOCKERHUB_USERNAME }}/endercube:${{ steps.version.outputs.VERSION }} | |
platforms: linux/amd64,linux/arm64/v8 | |
release: | |
needs: docker-push | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Restart server | |
uses: appleboy/ssh-action@v1.0.1 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: ~/EndercubeRelease/update.sh | |