mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
91 lines
2.3 KiB
YAML
91 lines
2.3 KiB
YAML
name: Build and Deploy Docker Images
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
ref:
|
|
description: Git Ref
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
name: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{inputs.ref}}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to Docker Hub
|
|
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: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Calculate Image Tags
|
|
env:
|
|
INPUT_REF: ${{inputs.ref}}
|
|
run: |
|
|
declare TAGS=""
|
|
case "${INPUT_REF}" in
|
|
v[0-9]*.[0-9]*.[0-9]*)
|
|
TAGS="${INPUT_REF}"
|
|
if [[ "$(git rev-parse origin/main)" = "$(git rev-parse "${INPUT_REF}")" ]]; then
|
|
TAGS="${TAGS} latest"
|
|
fi
|
|
;;
|
|
[0-9]*.[0-9]*.[0-9]*-nightly)
|
|
TAGS="${INPUT_REF} nightly"
|
|
;;
|
|
*)
|
|
echo "Invalid Input Ref: ${INPUT_REF}"
|
|
exit 1
|
|
esac
|
|
|
|
if [[ -z "${TAGS}" ]]; then
|
|
echo "Empty Tags!"
|
|
exit 1
|
|
fi
|
|
|
|
{
|
|
echo 'DOCKER_IMAGE_TAGS<<EOF'
|
|
for tag in ${TAGS}; do
|
|
echo "viren070/aiostreams:${tag}"
|
|
echo "ghcr.io/viren070/aiostreams:${tag}"
|
|
done
|
|
echo EOF
|
|
} >> "${GITHUB_ENV}"
|
|
|
|
cat "${GITHUB_ENV}"
|
|
|
|
- name: Build & Push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
context: .
|
|
file: ./Dockerfile
|
|
tags: ${{env.DOCKER_IMAGE_TAGS}}
|