Skip to content

Build and Push Docker Image #71

Build and Push Docker Image

Build and Push Docker Image #71

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: echo "GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Set version
run: sed -i 's/<version>/'"${{ inputs.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: Get last image rc version
if: ${{ github.head_ref == 'master' }}
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
echo "NEXT_RC_VERSION=$(($CURRENT_RC_VERSION + 1))" >> $GITHUB_ENV
- 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=${{ github.head_ref != 'release' && 'dev-' || '' }},onlatest=true
suffix=${{ github.head_ref == 'master' && '-rc.$NEXT_RC_VERSION' || '' }},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 }}