readme updates, fixed out of bounds exception #130
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: Create and publish a Docker image | |
on: | |
push: | |
branches: | |
- master | |
- dev | |
tags: | |
- 'v*' | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
data: | |
- image-name: solarthing | |
display-name: "SolarThing" | |
build-command: "client:shadowJar" | |
jar-location: "client/build/libs/client-0.0.1-SNAPSHOT-all.jar" | |
- image-name: solarthing-server | |
display-name: "SolarThing Server" | |
build-command: "server:bootJar" | |
jar-location: "server/build/libs/server-0.0.1-SNAPSHOT.jar" | |
env: | |
platforms: ${{ github.ref == 'refs/heads/dev' && 'linux/amd64,linux/arm/v7' || 'linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x' }} | |
steps: | |
# https://github.com/marketplace/actions/checkout | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
# https://github.com/marketplace/actions/setup-java-jdk#supported-distributions | |
distribution: 'temurin' | |
java-version: 17 | |
- if: matrix.data.image-name == 'solarthing-server' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- if: matrix.data.image-name == 'solarthing-server' | |
name: Install dependencies | |
run: (cd web && npm install) | |
- name: Build Jar | |
run: ./gradlew ${{ matrix.data.build-command }} | |
# https://github.com/marketplace/actions/docker-login | |
- name: Log in to the Container registry | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# https://github.com/marketplace/actions/docker-metadata-action | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/wildmountainfarms/${{ matrix.data.image-name }} | |
# expressions: https://docs.github.com/en/actions/learn-github-actions/expressions | |
tags: | | |
# in our case {{major}} is actually a year, so it's not really signifying a major release | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=raw,value=latest,priority=750,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') && !contains(github.ref, 'beta') }} | |
type=raw,value=beta,priority=740,enable=${{ startsWith(github.ref, 'refs/tags/')}} | |
type=edge,branch=master | |
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
type=sha,format=short | |
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys | |
labels: | | |
maintainer=retrodaredevil | |
org.opencontainers.image.title=${{ matrix.data.display-name }} | |
org.opencontainers.image.description=${{ matrix.data.display-name }} running in a docker container | |
org.opencontainers.image.source=https://github.com/wildmountainfarms/solarthing | |
org.opencontainers.image.ref.name=${{ matrix.data.image-name }} | |
org.opencontainers.image.vendor=wildmountainfarms | |
org.opencontainers.image.documentation=https://solarthing.readthedocs.io/en/latest/ | |
org.opencontainers.image.url=https://solarthing.readthedocs.io/en/latest/ | |
org.opencontainers.image.authors=retrodaredevil | |
org.opencontainers.image.base.name=docker.io/eclipse-temurin:19-jre-jammy | |
# https://github.com/marketplace/actions/docker-setup-buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# https://github.com/marketplace/actions/build-and-push-docker-images | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: docker/${{ matrix.data.image-name }}/Dockerfile | |
build-args: | | |
JAR_LOCATION=${{ matrix.data.jar-location }} | |
COMMIT_HASH=${{ github.sha }} | |
REF=${{ github.ref }} | |
push: true | |
platforms: ${{ env.platforms }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |