Update to api.papermc.io (#220) #69
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 and Publish | |
on: | |
push: | |
branches: | |
- master | |
- test/* | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
paths-ignore: | |
- "*.md" | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
variant: | |
- java21 | |
- java17 | |
- java11 | |
- java8 | |
include: | |
- variant: java17 | |
baseImage: eclipse-temurin:17-focal | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
tagPrefix: java17- | |
- variant: java21 | |
baseImage: eclipse-temurin:21-jre | |
platforms: linux/amd64,linux/arm64 | |
tagPrefix: java21- | |
- variant: java8 | |
baseImage: adoptopenjdk:8-jre-hotspot-focal | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
tagPrefix: java8- | |
- variant: java11 | |
baseImage: adoptopenjdk:11-jre-hotspot-focal | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
tagPrefix: java11- | |
env: | |
DOCKER_HUB_ORG: itzg | |
MAIN_VARIANT: java21 | |
steps: | |
- uses: actions/[email protected] | |
- name: Docker meta | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: | | |
${{ env.DOCKER_HUB_ORG }}/bungeecord | |
${{ env.DOCKER_HUB_ORG }}/mc-proxy | |
ghcr.io/${{ github.repository_owner }}/mc-proxy | |
tags: | | |
# For the "main" variant, it gets the tag as-is, without suffix | |
type=ref,event=tag,enable=${{ matrix.variant == env.MAIN_VARIANT }} | |
# and each variant (including main one) gets the tag with the variant suffix, such as 2023.1.1-java17 | |
type=ref,event=tag,suffix=-${{ matrix.variant }} | |
# latest repo tag gets a moving 'stable' image tag applied to the main variant | |
type=raw,value=stable,enable=${{ github.ref_type == 'tag' && matrix.variant == env.MAIN_VARIANT }} | |
# apply the variant as a moving tag for most recent commit per variant | |
type=raw,value=${{ matrix.variant }},enable=${{ github.ref_name == github.event.repository.default_branch }} | |
# for building test/* branch images | |
type=ref,event=branch,suffix=-${{ matrix.variant }},enable=${{ github.ref_name != github.event.repository.default_branch }} | |
# legacy tag format of {variant}-{version} | |
type=ref,event=tag,prefix=${{ matrix.tagPrefix }} | |
# NOTE this identifies which variant will be published as "latest", which isn't | |
# necessarily the newest version of Java | |
flavor: | | |
latest=${{ matrix.variant == env.MAIN_VARIANT && github.ref_name == github.event.repository.default_branch }} | |
- name: Setup Docker Buildx | |
uses: docker/[email protected] | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/[email protected] | |
with: | |
platforms: ${{ matrix.platforms }} | |
# ensure latest base image is used | |
pull: true | |
push: true | |
build-args: | | |
BASE_IMAGE=${{ matrix.baseImage }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha,scope=${{ matrix.variant }} | |
cache-to: type=gha,mode=max,scope=${{ matrix.variant }} |