Skip to content

Merge pull request #65 from rHomelab/feat/noaudio_build #184

Merge pull request #65 from rHomelab/feat/noaudio_build

Merge pull request #65 from rHomelab/feat/noaudio_build #184

Workflow file for this run

name: Build/Push Image
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
push:
description: 'Push'
required: false
type: boolean
default: true
env:
IMAGE_NAME: red-discordbot
jobs:
build:
name: Build ${{ matrix.variant.name }} variant
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- name: "default"
build_args: ""
tag_suffix: ""
- name: "noaudio"
build_args: "SKIP_JRE=1"
tag_suffix: "-noaudio"
steps:
- uses: actions/checkout@v5
- name: Get Red version and define tags
id: build_info
run: |
RED_VERSION=$(cat ./redbot/requirements.txt | grep 'Red-DiscordBot' | sed -e 's/Red-DiscordBot\s\?==\s\?//g')
echo "red_version=$RED_VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Gather Docker metadata
uses: docker/metadata-action@v5
id: meta
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest${{ matrix.variant.tag_suffix }},enable={{is_default_branch}}
type=semver,pattern={{version}}${{ matrix.variant.tag_suffix }},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
type=semver,pattern={{major}}.{{minor}}${{ matrix.variant.tag_suffix }},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
type=semver,pattern={{major}}${{ matrix.variant.tag_suffix }},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
type=ref,event=pr,suffix=${{ matrix.variant.tag_suffix }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
push: ${{ inputs.push != 'false' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: linux/amd64,linux/arm64
build-args: ${{ matrix.variant.build_args }}
# Build cache is scoped to branches by default.
# We use the main branch as a fallback if there's no cache for the existing branch.
# https://stackoverflow.com/a/77127188/5209106
cache-from: |
type=gha,scope=${{ matrix.variant.name }}
type=gha,scope=main-${{ matrix.variant.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.variant.name }}
provenance: false