Build-daily #363
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: Build-daily | |
# Controls when the workflow will run | |
on: | |
schedule: | |
- cron: 0 0 * * * | |
workflow_dispatch: | |
push: | |
branches: | |
- 'daily-build' | |
- 'main' | |
jobs: | |
build-matrix: | |
strategy: | |
matrix: | |
platform: [arm64,amd64] | |
runs-on: ubuntu-latest | |
steps: | |
# Get the repository's code | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Scrape latest necesse server download url, download, unzip, and rename | |
run: | | |
NURL=$(curl -s https://necessegame.com/server/ | grep -Eo 'content\/server\/[0-9]?[0-9]-[0-9]?[0-9]-[0-9]?[0-9]-[0-9]+\/necesse-server-linux64-[0-9]?[0-9]-[0-9]?[0-9]-[0-9]?[0-9]-[0-9]+.zip' | echo "$(echo 'https://necessegame.com/')$(head -n 1)") | |
NBuildNum=$(echo $NURL | grep -Eo '\-[0-9]+\.' | grep -Eo '[0-9]+') | |
echo "NBuildNum=$NBuildNum" >> $GITHUB_ENV | |
wget $NURL | |
unzip necesse-server-linux64-* | |
rm necesse-server-linux64-* | |
mv necesse-server-* necesse-server | |
- name: Fetch jre and replace runtime for arm64 | |
if: matrix.platform == 'arm64' | |
run: | | |
rm -r necesse-server/jre/* | |
wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jre_aarch64_linux_hotspot_17.0.8.1_1.tar.gz | |
tar -xf OpenJDK17U-jre_aarch64_linux_hotspot_17.0.8.1_1.tar.gz | |
cp -r jdk-17.0.8.1+1-jre/* necesse-server/jre/ | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
build-args: | | |
JAVAPLATFORM=linux/${{ matrix.platform }} | |
platforms: linux/${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: karyeet/necesse-server-docker:${{ matrix.platform }}-${{ env.NBuildNum }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-docker-multiarch: | |
runs-on: ubuntu-latest | |
needs: [build-matrix] | |
steps: | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create and push multiarch image | |
run: | | |
NURL=$(curl -s https://necessegame.com/server/ | grep -Eo 'content\/server\/[0-9]?[0-9]-[0-9]?[0-9]-[0-9]?[0-9]-[0-9]+\/necesse-server-linux64-[0-9]?[0-9]-[0-9]?[0-9]-[0-9]?[0-9]-[0-9]+.zip' | echo "$(echo 'https://necessegame.com/')$(head -n 1)") | |
NBuildNum=$(echo $NURL | grep -Eo '\-[0-9]+\.' | grep -Eo '[0-9]+') | |
docker buildx imagetools create -t karyeet/necesse-server-docker:$NBuildNum -t karyeet/necesse-server-docker:latest \ | |
karyeet/necesse-server-docker:arm64-$NBuildNum \ | |
karyeet/necesse-server-docker:amd64-$NBuildNum |