From e941a7b3e639160fd6d4ba217c4226a06068e625 Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Fri, 29 Mar 2024 11:33:23 +0100 Subject: [PATCH 1/4] add version checking --- .github/workflows/release.yml | 2 ++ Dockerfile | 8 ++++++++ scripts/helper_functions.sh | 25 +++++++++++++++++++++++++ scripts/helper_install.sh | 4 ++-- scripts/start.sh | 5 +++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5f9eff0..58713ab6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,3 +53,5 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + build-args: | + GIT_VERSION_TAG=${{ github.ref }} diff --git a/Dockerfile b/Dockerfile index cbea3cfa..c70afa33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,6 +51,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gettext-base=0.21-12 \ xdg-user-dirs=0.18-1 \ jo=1.9-1 \ + jq=1.6-2.1 \ netcat-traditional=1.10-47 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -145,6 +146,9 @@ ENV HOME=/home/steam \ ARM_COMPATIBILITY_MODE=false \ DISABLE_GENERATE_ENGINE=true +# Passed from Github Actions +ARG GIT_VERSION_TAG=unspecified + COPY ./scripts /home/steam/server/ RUN chmod +x /home/steam/server/*.sh && \ @@ -153,6 +157,10 @@ RUN chmod +x /home/steam/server/*.sh && \ mv /home/steam/server/restore.sh /usr/local/bin/restore WORKDIR /home/steam/server + +# Make GIT_VERSION_TAG file to be able to check the version +RUN echo $GIT_VERSION_TAG > GIT_VERSION_TAG + RUN touch rcon.yaml crontab && \ mkdir -p /home/steam/Steam/package && \ chown steam:steam /home/steam/Steam/package && \ diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 7a7c92a9..c0a6ce42 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -259,3 +259,28 @@ countdown_message() { fi return "$return_val" } + +container_version_check() { + local current_version + local latest_version + + current_version=$(cat /home/steam/server/GIT_VERSION_TAG) + latest_version=$(get_latest_version) + + if [ "${current_version}" != "${latest_version}" ]; then + LogWarn "New version available: ${latest_version}" + LogWarn "Learn how to update the container: https://palworld-server-docker.loef.dev/guides/update-the-container" + else + LogSuccess "The container is up to date!" + + fi +} +# Get latest release version from thijsvanloef/palworld-server-docker repository +# Returns the latest release version +get_latest_version() { + local latest_version + + latest_version=$(curl https://api.github.com/repos/thijsvanloef/palworld-server-docker/releases/latest -s | jq .name -r) + + echo "$latest_version" +} \ No newline at end of file diff --git a/scripts/helper_install.sh b/scripts/helper_install.sh index 1f0a826c..19021bb5 100644 --- a/scripts/helper_install.sh +++ b/scripts/helper_install.sh @@ -53,7 +53,7 @@ EOL # Returns 1 if Update NOT Required # Returns 2 if Check Failed UpdateRequired() { - LogAction "Checking for new update" + LogAction "Checking for new Palworld Server updates" #define local variables local CURRENT_MANIFEST LATEST_MANIFEST temp_file http_code updateAvailable @@ -102,7 +102,7 @@ UpdateRequired() { # Warn if version is locked if [ "$updateAvailable" == false ]; then - LogSuccess "The Server is up to date!" + LogSuccess "The server is up to date!" return 1 fi diff --git a/scripts/start.sh b/scripts/start.sh index a747ad76..4025bb76 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -103,6 +103,9 @@ if [ "${TARGET_MANIFEST_ID}" == "3750364703337203431" ] && [ "${RCON_ENABLED,,}" STARTCOMMAND+=("-rcon") fi +LogAction "Checking for available container updates" +container_version_check + if [ "${DISABLE_GENERATE_SETTINGS,,}" = true ]; then LogAction "GENERATING CONFIG" LogWarn "Env vars will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!" @@ -130,8 +133,10 @@ fi if [ "${DISABLE_GENERATE_ENGINE,,}" = false ]; then /home/steam/server/compile-engine.sh || exit fi + LogAction "GENERATING CRONTAB" truncate -s 0 "/home/steam/server/crontab" + if [ "${BACKUP_ENABLED,,}" = true ]; then LogInfo "BACKUP_ENABLED=${BACKUP_ENABLED,,}" LogInfo "Adding cronjob for auto backups" From 9c2fa01349809fcc6a0e2c9b3ece56772f674b76 Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Fri, 29 Mar 2024 11:35:25 +0100 Subject: [PATCH 2/4] disable docker push for now --- .github/workflows/release.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58713ab6..7a7d6a86 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,11 +13,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Docker - Login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + # - name: Docker - Login + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} - name: Docker - GHCR Login uses: docker/login-action@v3 @@ -37,7 +37,6 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ${{ github.repository }} ghcr.io/${{ github.repository }} # generate Docker tags based on the following events/attributes tags: | From 7f630d9c42014ea48ecdc95d1c2164ebc2437341 Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Fri, 29 Mar 2024 11:52:07 +0100 Subject: [PATCH 3/4] change variable --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a7d6a86..fb43b7d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,4 +53,4 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} build-args: | - GIT_VERSION_TAG=${{ github.ref }} + GIT_VERSION_TAG=${{ github.event.release.tag_name }} From 7a22482e6a42e9829a90c5ba227eca9ce159245a Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Fri, 29 Mar 2024 11:58:36 +0100 Subject: [PATCH 4/4] revert push to docker hub --- .github/workflows/release.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb43b7d7..1334f78f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,11 +13,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # - name: Docker - Login - # uses: docker/login-action@v3 - # with: - # username: ${{ secrets.DOCKER_USERNAME }} - # password: ${{ secrets.DOCKER_PASSWORD }} + - name: Docker - Login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Docker - GHCR Login uses: docker/login-action@v3 @@ -37,6 +37,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | + ${{ github.repository }} ghcr.io/${{ github.repository }} # generate Docker tags based on the following events/attributes tags: |