Skip to content

Add Docker multi-bot deployment flow #1

Add Docker multi-bot deployment flow

Add Docker multi-bot deployment flow #1

name: Container Image
on:
push:
branches: [master]
tags:
- "v*"
- "*.*.*"
pull_request:
branches: [master]
workflow_dispatch:
concurrency:
group: container-image-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
jobs:
docker:
name: Build Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute image name
id: prep
shell: bash
run: echo "image=${REGISTRY}/${GITHUB_REPOSITORY_OWNER,,}/discordmusicbot" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.prep.outputs.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix=sha-
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and optionally push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
pull: true
push: ${{ github.event_name != 'pull_request' }}
provenance: false
sbom: false
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}