Switch to Github Action
This commit is contained in:
parent
56a49f1357
commit
da6756c829
54
.github/workflows/build.yml
vendored
Normal file
54
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# 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 and Upload to DockerHub
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-gradle:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 1.8
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- 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]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Get build number
|
||||||
|
id: get_version
|
||||||
|
run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_RUN_NUMBER})
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v1.0.0
|
||||||
|
with:
|
||||||
|
# Artifact name
|
||||||
|
name: claptrap_jar
|
||||||
|
# Destination path
|
||||||
|
path: build/libs/
|
||||||
|
- name: Publish Docker
|
||||||
|
uses: elgohr/Publish-Docker-Github-Action@master
|
||||||
|
with:
|
||||||
|
name: brokenfire/brokendiscordbot
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
tags: "latest,${{ env.RELEASE_VERSION }}"
|
||||||
|
buildargs: GITHUB_RUN_NUMBER=${{env.RELEASE_VERSION}}
|
12
Dockerfile
12
Dockerfile
@ -1,13 +1,11 @@
|
|||||||
FROM debian:latest
|
FROM openjdk:8-jre-buster
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get -y upgrade
|
|
||||||
RUN apt-get -y install openjdk-8-jre openjdk-8-jdk curl wget
|
|
||||||
WORKDIR /bot_src
|
WORKDIR /bot_src
|
||||||
ARG BUILD_NBR
|
ARG BUILD_NBR
|
||||||
ARG BRANCH_NAME
|
ARG BRANCH_NAME
|
||||||
ADD DownloadLast.sh /bot_src/
|
ARG BRANCH_NAME
|
||||||
RUN chmod +x DownloadLast.sh
|
ARG GITHUB_RUN_NUMBER
|
||||||
RUN ./DownloadLast.sh ${BRANCH_NAME} ${BUILD_NBR}
|
ADD build/libs/ClaptrapBot-*.jar /bot_src/bot.jar
|
||||||
|
RUN java -version
|
||||||
ENV PORT=8080
|
ENV PORT=8080
|
||||||
ENV TOKEN=10
|
ENV TOKEN=10
|
||||||
CMD java -jar bot.jar -t ${TOKEN}
|
CMD java -jar bot.jar -t ${TOKEN}
|
||||||
|
74
Jenkinsfile
vendored
74
Jenkinsfile
vendored
@ -1,74 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
stages {
|
|
||||||
|
|
||||||
stage('Clone') { // for display purposes
|
|
||||||
// Get some code from a GitHub repository
|
|
||||||
steps {
|
|
||||||
echo env.BRANCH_NAME
|
|
||||||
script {
|
|
||||||
if (env.BRANCH_NAME == 'master') {
|
|
||||||
git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'master'
|
|
||||||
} else {
|
|
||||||
git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'devel'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
stage('Gradle Build'){
|
|
||||||
steps{
|
|
||||||
script {
|
|
||||||
if (env.BRANCH_NAME == 'master') {
|
|
||||||
build job: 'Bot Discord Gradle', wait: true
|
|
||||||
} else {
|
|
||||||
build job: 'Bot Discord Gradle devel', wait: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
stage('Build Docker image') {
|
|
||||||
/* This builds the actual image; synonymous to
|
|
||||||
* docker build on the command line */
|
|
||||||
steps{
|
|
||||||
script{
|
|
||||||
app = docker.build("brokenfire/brokendiscordbot",'--build-arg BUILD_NBR=${BUILD_NUMBER} --build-arg BRANCH_NAME=${BRANCH_NAME} --rm=true .')
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
stage('Push Docker image') {
|
|
||||||
/* Finally, we'll push the image with two tags:
|
|
||||||
* First, the incremental build number from Jenkins
|
|
||||||
* Second, the 'latest' tag.
|
|
||||||
* Pushing multiple tags is cheap, as all the layers are reused. */
|
|
||||||
steps{
|
|
||||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'docker-hub-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
|
|
||||||
sh 'docker login -u $USERNAME -p $PASSWORD'
|
|
||||||
script {
|
|
||||||
if (env.BRANCH_NAME == 'master') {
|
|
||||||
app.push("master")
|
|
||||||
} else {
|
|
||||||
app.push("devel")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
stage('Cleaning'){
|
|
||||||
steps{
|
|
||||||
sh "docker image prune -f"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,7 @@ plugins {
|
|||||||
def versionObj = new Version(major: 0, minor: 2, revision: 0)
|
def versionObj = new Version(major: 0, minor: 2, revision: 0)
|
||||||
|
|
||||||
group = "net.broken"
|
group = "net.broken"
|
||||||
archivesBaseName = "BrokenDiscordBot"
|
archivesBaseName = "ClaptrapBot"
|
||||||
version = "$versionObj"
|
version = "$versionObj"
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
@ -23,7 +23,7 @@ jar.doFirst {
|
|||||||
|
|
||||||
jar {
|
jar {
|
||||||
// delete "${buildDir}/libs/*"
|
// delete "${buildDir}/libs/*"
|
||||||
baseName = 'DiscordBot'
|
// baseName = 'DiscordBot'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class Version {
|
|||||||
String major, minor, revision
|
String major, minor, revision
|
||||||
|
|
||||||
static String getBuild() {
|
static String getBuild() {
|
||||||
System.getenv("BUILD_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?:
|
System.getenv("GITHUB_RUN_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?:
|
||||||
System.getenv("GIT_COMMIT")?.substring(0, 7) ?: System.getProperty("GIT_COMMIT")?.substring(0, 7) ?:"DEV"
|
System.getenv("GIT_COMMIT")?.substring(0, 7) ?: System.getProperty("GIT_COMMIT")?.substring(0, 7) ?:"DEV"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user