49 lines
1.4 KiB
YAML
49 lines
1.4 KiB
YAML
name: Build and Push Docker image
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main", "feature/*" ]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/discordsoundbot-vib
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Generate Docker tag
|
|
id: docker_tag
|
|
run: |
|
|
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
|
echo "tag=main" >> $GITHUB_OUTPUT
|
|
else
|
|
# Ersetze Slashes durch Bindestriche für gültige Docker Tags
|
|
CLEAN_TAG=$(echo "${{ github.ref_name }}" | sed 's/\//-/g')
|
|
echo "tag=$CLEAN_TAG" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
build-args: |
|
|
REACT_APP_VERSION=${{ steps.docker_tag.outputs.tag == 'main' && 'stable' || 'nightly' }}
|
|
tags: |
|
|
${{ env.IMAGE_NAME }}:latest
|
|
${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
${{ env.IMAGE_NAME }}:${{ steps.docker_tag.outputs.tag }}
|
|
platforms: linux/amd64
|