mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
101 lines
2.7 KiB
YAML
101 lines
2.7 KiB
YAML
name: Build and Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- java8
|
|
- openj9
|
|
- openj9-11
|
|
- adopt11
|
|
- test/*
|
|
tags:
|
|
- "[0-9]+.[0-9]+.[0-9]+-java8"
|
|
- "[0-9]+.[0-9]+.[0-9]+-openj9"
|
|
- "[0-9]+.[0-9]+.[0-9]+-openj9-11"
|
|
- "[0-9]+.[0-9]+.[0-9]+-openj9-nightly"
|
|
- "[0-9]+.[0-9]+.[0-9]+-adopt11"
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2.3.4
|
|
|
|
- name: Run tests
|
|
run: |
|
|
tests/test.sh
|
|
build:
|
|
needs:
|
|
- test
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2.3.4
|
|
|
|
- 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=version::${VERSION//\//-}
|
|
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v2.1.6
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
id: docker_build
|
|
uses: docker/build-push-action@v2.7.0
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
# ensure latest base image is used
|
|
pull: true
|
|
# publish
|
|
push: true
|
|
# tags determined by prep step
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
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 }}
|
|
|
|
- # Temp fix
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
name: Move cache
|
|
run: |
|
|
rm -rf /tmp/.buildx-cache
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|