Skip to content

Commit

Permalink
Publish to GH container registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Jul 12, 2024
1 parent cf5e27b commit 8f94cc1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: Build
name: Build and Publish

on: [ push ]

env:
IMAGE_NAME: GlobalLinkServer

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -22,13 +27,20 @@ jobs:
arguments: build
cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }}

- name: Archive artifact
uses: actions/upload-artifact@v3
if: success()
with:
name: GlobalLinkServer
path: build/libs/GlobalLinkServer.jar
if-no-files-found: error
- name: Build image
run: docker build . -t $IMAGE_NAME --label "run-number=${GITHUB_RUN_ID}"
- name: Registry login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Notify Discord
if: ${{ (success() || failure()) && github.repository == 'GeyserMC/GlobalLinkServer' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
!README.md
!.github
!.github/**
!Dockerfile

# Don't ignore specific gradle files and folders
!gradle
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM eclipse-temurin:21-jre

WORKDIR /app
COPY build/libs/GlobalLinkServer.jar GlobalLinkServer.jar

CMD ["java", "-jar", "GlobalLinkServer.jar"]

0 comments on commit 8f94cc1

Please sign in to comment.