Skip to content

Core - Release Docker #3

Core - Release Docker

Core - Release Docker #3

name: Core - Release Docker
on:
release:
types: [published]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}_core
jobs:
core-release-docker:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./core
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: set up QEMU
uses: docker/setup-qemu-action@v2
- name: set up docker buildx
uses: docker/setup-buildx-action@v2
- name: log in to the container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: string_tag
uses: ASzc/change-string-case-action@v5
with:
string: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}
- id: release_asset
name: Download release assets
uses: dsaltares/fetch-gh-release-asset@master
with:
regex: true
file: "lodestone_core_*"
target: release/
version: "tags/${{ github.event.release.tag_name }}"
token: ${{ secrets.GITHUB_TOKEN }}
# https://stackoverflow.com/questions/73402042/github-action-expressions-split-string
- name: set version string
env:
VERSION: ${{ steps.release_asset.outputs.version }}
id: substring
run: echo "version=${VERSION:1}" >> $GITHUB_OUTPUT
- name: set docker version label
env:
LABEL: ${{ !github.event.release.prerelease && 'latest-stable' || 'latest-beta' }}
id: release_type
run: echo "label=${LABEL}" >> $GITHUB_OUTPUT
- name: build and push
uses: docker/build-push-action@v3
with:
context: ./core
platforms: linux/amd64,linux/arm64
file: ./githubactions.Dockerfile
build-args: |
lodestone_version=${{ steps.release_asset.outputs.version }}
push: true
tags: |
${{ steps.string_tag.outputs.lowercase }}:latest
${{ steps.string_tag.outputs.lowercase }}:${{ steps.release_type.outputs.label }}
${{ steps.string_tag.outputs.lowercase }}:${{ steps.substring.outputs.version }}