Skip to content

Commit 31574ca

Browse files
committed
Add actions workflow
1 parent 9240dc0 commit 31574ca

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

.github/workflows/build.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths-ignore:
7+
- '.idea/copyright/*.xml'
8+
- '.gitignore'
9+
- 'LICENSE'
10+
- 'README.md'
11+
12+
env:
13+
DOCKER_OWNER: ${{ github.repository_owner }}
14+
DOCKER_CONTAINER: server-ping-api
15+
DOCKER_TAG: ${{ github.ref_name }}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: 17
26+
distribution: temurin
27+
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
31+
- name: Build ServerPingApi
32+
uses: gradle/gradle-build-action@v2
33+
with:
34+
arguments: build
35+
36+
- name: Archive artifacts
37+
uses: actions/upload-artifact@v3
38+
if: success()
39+
with:
40+
name: GeyserBot
41+
path: build/libs/GeyserBot.jar
42+
43+
# Docker image build
44+
- name: Fix Docker environment variables
45+
run: |
46+
# Make lowercase
47+
echo "DOCKER_OWNER=$(echo $DOCKER_OWNER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
48+
echo "DOCKER_CONTAINER=$(echo $DOCKER_CONTAINER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
49+
echo "DOCKER_TAG=$(echo $DOCKER_TAG | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
50+
51+
# Replace / with _
52+
echo "DOCKER_TAG=$(echo $DOCKER_TAG | sed -e 's/\//_/g')" >> $GITHUB_ENV
53+
54+
- name: Build the Docker image
55+
run: |
56+
docker build . --file Dockerfile --tag $DOCKER_CONTAINER:$DOCKER_TAG
57+
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker tag $DOCKER_CONTAINER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
58+
docker tag $DOCKER_CONTAINER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG
59+
60+
- name: Log in to registry
61+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
62+
63+
- name: Push to GHCR
64+
run: |
65+
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
66+
docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG

.github/workflows/pullrequest.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build Pull Request
2+
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
paths-ignore:
8+
- '.idea/copyright/*.xml'
9+
- '.gitignore'
10+
- 'LICENSE'
11+
- 'README.md'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: 17
22+
distribution: temurin
23+
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
27+
- name: Build GeyserBot
28+
uses: gradle/gradle-build-action@v2
29+
with:
30+
arguments: build
31+
32+
- name: Archive artifacts
33+
uses: actions/upload-artifact@v3
34+
if: success()
35+
with:
36+
name: GeyserBot
37+
path: build/libs/GeyserBot.jar

0 commit comments

Comments
 (0)