Skip to content

B&D false/cosmos_openwebui:main #88

B&D false/cosmos_openwebui:main

B&D false/cosmos_openwebui:main #88

name: build_push_image
run-name: B&D ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:${{ github.event.inputs.tags }}
on:
workflow_dispatch:
inputs:
build_folder:
description: 'From which folder, the Dockerfiles will be built'
type: string
required: false
default: 'cosmos_llamacpp'
tags:
description: 'Customize image tags'
type: string
required: false
default: 'latest'
hub_username:
description: 'Docker hub username'
type: string
required: false
default: 'brokenjade'
jobs:
build_docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-${{ github.event.inputs.build_folder }}
restore-keys: |
buildx-${{ github.event.inputs.build_folder }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: ${{ github.event.inputs.hub_username != 'false' }}
uses: docker/login-action@v3
with:
username: ${{ github.event.inputs.hub_username }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Test
id: tag
run: |
tags=${{ github.event.inputs.tags }}
IFS=',' read -ra TAG_ARRAY <<< "$tags"
for tag in "${TAG_ARRAY[@]}"; do
echo ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:$tag
done
echo "tag0=${TAG_ARRAY[0]}" >> $GITHUB_OUTPUT
- name: Build
run: |
pwd
cd ${{ github.event.inputs.build_folder }}
ls
cat Dockerfile
docker build -t ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:temp .
tags=${{ github.event.inputs.tags }}
IFS=',' read -ra TAG_ARRAY <<< "$tags"
for tag in "${TAG_ARRAY[@]}"; do
docker tag ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:temp ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:$tag
done
- name: list images
run: docker images
- name: publish
if: ${{ github.event.inputs.hub_username != 'false' }}
run: |
tags=${{ github.event.inputs.tags }}
IFS=',' read -ra TAG_ARRAY <<< "$tags"
for tag in "${TAG_ARRAY[@]}"; do
echo ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:$tag
docker image push ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:$tag
done
- name: Update Docker Hub Description
if: ${{ github.event.inputs.hub_username != 'false' }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ github.event.inputs.hub_username }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}
readme-filepath: "${{ github.event.inputs.build_folder }}/README.MD"
# only works if built on self-hosted runners. Github runners do not have enough space for this.
# - name: Save image as a tar for later use 💾
# run: docker save ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:${{ github.event.inputs.tag }} -o /tmp/${{ github.event.inputs.hub_username }}-${{ github.event.inputs.build_folder }}.tar
# shell: bash
# - name: Upload image as artifact 💾
# uses: actions/upload-artifact@v3
# with:
# name: ${{ github.event.inputs.hub_username }}-${{ github.event.inputs.build_folder }}
# path: /tmp/${{ github.event.inputs.hub_username }}-${{ github.event.inputs.build_folder }}.tar
# retention-days: 3
- name: Save image as a tar for later use
run: |
# Export the image to a tar file
mkdir -p artifacts
echo "docker save ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:${{ steps.tag.outputs.tag0 }} -o artifacts/docker-${{ github.event.inputs.build_folder }}.tar"
docker save ${{ github.event.inputs.hub_username }}/${{ github.event.inputs.build_folder }}:${{ steps.tag.outputs.tag0 }} -o artifacts/docker-${{ github.event.inputs.build_folder }}.tar
- name: Install 7zip
run: sudo apt-get install -y p7zip-full
- name: Split Docker image into volumes
run: |
cd artifacts
7z a -v2g docker-${{ github.event.inputs.build_folder }}-volumes.7z docker-${{ github.event.inputs.build_folder }}.tar
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.build_folder }}-${{ github.event.inputs.tags }}
release_name: Docker image ${{ github.event.inputs.build_folder }}:${{ github.event.inputs.tags }}
draft: false
prerelease: false
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: artifacts/docker-${{ github.event.inputs.build_folder }}-volumes.*
tag_name: ${{ github.event.inputs.build_folder }}-${{ github.event.inputs.tags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}