Skip to content

Build and Push Docker Image #87

Build and Push Docker Image

Build and Push Docker Image #87

Workflow file for this run

name: build romm image
on:
workflow_dispatch:
inputs:
version:
description: "romm version"
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set environment variables
run: |
CURRENT_RC_VERSION=$(wget -q -O - "https://hub.docker.com/v2/repositories/zurdi15/romm/tags?page_size=2" | grep -o '"name": *"[^"]*' | grep -o '[^"]*$' | grep "dev-${{ inputs.version }}-rc" | cut -d "-" -f 3 | cut -d "." -f 2)
[[ -z $CURRENT_RC_VERSION ]] && CURRENT_RC_VERSION=0
NEXT_RC_VERSION="$(($CURRENT_RC_VERSION + 1))"
echo "VERSION_PREFIX=${{ github.ref != format('refs/heads/{0}', 'release') && 'dev-' || '' }}" >> $GITHUB_ENV
echo "VERSION_SUFFIX=${{ github.ref == format('refs/heads/{0}', 'master') && '-rc.$NEXT_RC_VERSION' || '' }}" >> $GITHUB_ENV
- name: Set version
run: |
version=${{ env.VERSION_PREFIX }}${{ inputs.version }}${{ env.VERSION_SUFFIX }}
sed -i 's/<version>/'"${version}"'/' backend/__version__.py
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
name=zurdi15/romm
name=ghcr.io/zurdi15/romm
flavor: |
# latest on release branch, prefix dev on other branches
latest=true
prefix=${{ env.VERSION_PREFIX }},onlatest=true
suffix=${{ env.VERSION_SUFFIX }},onlatest=false
tags: |
type=raw,value=${{ inputs.version }}
labels: |
org.opencontainers.image.version=${{ inputs.version }}
org.opencontainers.image.title="zurdi15/romm"
org.opencontainers.image.description="RomM (stands for Rom Manager) is a game library manager focused in retro gaming. Manage and organize all of your games from a web browser"
org.opencontainers.image.licenses="GPL-3.0"
- name: Build image
uses: docker/build-push-action@v4
with:
file: docker/Dockerfile
context: .
push: true
platforms: linux/arm64,linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}