2020-06-20 21:01:27 +00:00
|
|
|
name: Build and Publish
|
2020-06-10 23:43:07 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-06-19 16:41:53 +00:00
|
|
|
branches:
|
|
|
|
- master
|
2021-01-31 00:32:32 +00:00
|
|
|
- java8
|
2020-06-19 16:41:53 +00:00
|
|
|
- openj9
|
2021-01-12 23:18:08 +00:00
|
|
|
- openj9-11
|
2020-06-19 16:41:53 +00:00
|
|
|
- adopt11
|
2021-01-09 20:13:18 +00:00
|
|
|
- test/*
|
2020-06-19 16:41:53 +00:00
|
|
|
tags:
|
2020-06-19 18:15:23 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+"
|
2021-01-31 00:32:32 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+-java8"
|
2020-06-19 18:15:23 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+-openj9"
|
2021-01-12 23:33:03 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+-openj9-11"
|
2020-06-19 18:15:23 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+-openj9-nightly"
|
|
|
|
- "[0-9]+.[0-9]+.[0-9]+-adopt11"
|
2020-06-10 23:43:07 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-07-11 19:09:08 +00:00
|
|
|
test:
|
2021-01-09 20:13:18 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2020-07-11 19:09:08 +00:00
|
|
|
|
|
|
|
steps:
|
2021-05-14 01:45:43 +00:00
|
|
|
- uses: actions/checkout@v2.3.4
|
2020-07-11 19:09:08 +00:00
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
tests/test.sh
|
2020-06-10 23:43:07 +00:00
|
|
|
build:
|
2020-07-11 19:09:08 +00:00
|
|
|
needs:
|
|
|
|
- test
|
2021-01-09 20:13:18 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2020-06-10 23:43:07 +00:00
|
|
|
|
|
|
|
steps:
|
2021-05-14 01:45:43 +00:00
|
|
|
- uses: actions/checkout@v2.3.4
|
2020-06-10 23:43:07 +00:00
|
|
|
|
2021-01-09 20:13:18 +00:00
|
|
|
- name: Prepare
|
|
|
|
id: prep
|
|
|
|
run: |
|
|
|
|
DOCKER_IMAGE=itzg/minecraft-server
|
|
|
|
VERSION=edge
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
|
|
fi
|
|
|
|
if [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/heads/}
|
|
|
|
if [[ $VERSION == master ]]; then
|
|
|
|
VERSION=latest
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
TAGS="${DOCKER_IMAGE}:${VERSION//\//-}"
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
|
|
echo ::set-output name=cache_from::${TAGS}
|
|
|
|
echo ::set-output name=version::${VERSION//\//-}
|
|
|
|
echo ::set-output name=cache_version::${VERSION//\//-}
|
|
|
|
|
|
|
|
- name: Setup Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-
|
2021-01-12 23:30:58 +00:00
|
|
|
${{ runner.os }}-buildx-
|
2021-01-09 20:13:18 +00:00
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
2020-06-10 23:43:07 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2021-01-09 20:13:18 +00:00
|
|
|
|
|
|
|
- name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
2021-01-12 23:20:57 +00:00
|
|
|
# ensure latest base image is used
|
|
|
|
pull: true
|
|
|
|
# publish
|
2020-06-20 20:35:37 +00:00
|
|
|
push: true
|
2021-01-12 23:20:57 +00:00
|
|
|
# tags determined by prep step
|
2021-01-09 20:13:18 +00:00
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server
|
|
|
|
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
|
|
|
|
org.opencontainers.image.source=https://github.com/itzg/docker-minecraft-server
|
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
|
|
|
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|