Skip to content

Commit

Permalink
Add workflows for building+publishing images & creating releases (#23)
Browse files Browse the repository at this point in the history
* Copy workflows & action from gstreamer

See https://github.com/selkies-project/selkies-gstreamer/tree/6faebf0942b5dbfb10c6cf51266ebbe83b359ac9/.github

* Add newlines for formatting

* Add name

* Add description

* Alphabetize inputs

* Add input descriptions

* Rename & simplify release creator

* Replace gstreamer logic with vdi template logic

* Reuse "all images" workflow for automation changes

* Generalize "changed images" workflow for future reuse

* Add WebRTC image build/publish automation

* Remove automation templates

* Default to use caching

* Add build/publish automation for images that are simple in cloudbuild

* Add app-streaming images build/publish automation

* Add app-proxy image build/publish automation

* Remove automatic triggers for untested image workflows

* Overwrite remaining stubs

* Simplify image names

* Fix alphabetization mistake

* Improve app-streaming image versioning

* Fix copy/paste typos

* Improve on-manual trigger descriptions

* Simplify triggers & authentication

* Simplify image builder job names

* Clone Xpra submodule when building xpra image

* Mark releases as drafts, for manual completion
  • Loading branch information
JanCVanB authored Jan 27, 2022
1 parent add32d1 commit 61a4a6e
Show file tree
Hide file tree
Showing 7 changed files with 667 additions and 32 deletions.
67 changes: 67 additions & 0 deletions .github/actions/build_and_publish_image/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build & publish an image

description: Build an image from source, then publish it to GHCR

inputs:
build_args:
description: '`ARG=value`s to pass to `docker build`'
required: false
dockerfile:
description: Image source file name
default: 'Dockerfile'
required: false
github_token:
description: A GitHub personal access token (PAT) that matches the username
required: true
github_username:
description: The GitHub user as whom to run this action
required: true
image_source_directory:
description: Image source directory path
required: true
image_name:
description: The basename for all image tags, such as "image" in "ghcr.io/user/repo/image:latest"
required: true
image_version_1:
description: A version for all image tags, such as "foo" in "ghcr.io/user/repo/image:foo"
required: true
image_version_2:
description: Another version for all image tags, such as "bar" in "ghcr.io/user/repo/image:bar"
required: false
image_version_suffix:
description: A suffix for all image tags, such as "-baz" in "ghcr.io/user/repo/image:foo-baz"
required: false
use_cache:
default: "true"
description: Use cached layers from pre-published image with tag 1 (true/false)
required: false

runs:
using: composite
steps:
- shell: bash
run: |
set -x
echo ${{ inputs.github_token }} | docker login ghcr.io -u ${{ inputs.github_username }} --password-stdin
export BUILD_ARGS=""
if [[ -n "${{ inputs.build_args }}" ]]; then
IFS=";" read -ra args <<< "${{ inputs.build_args }}"
for arg in ${args[@]}; do BUILD_ARGS+="--build-arg $arg "; done
fi
export IMAGE_TAG_URL_PREFIX=ghcr.io/selkies-project/selkies-vdi/
export IMAGE_TAG_1="${IMAGE_TAG_URL_PREFIX}${{ inputs.image_name }}:${{ inputs.image_version_1 }}${{ inputs.image_version_suffix }}"
if [[ "${{ inputs.use_cache }}" == "true" ]]; then
docker pull $IMAGE_TAG_1 || true
(cd ${{ inputs.image_source_directory }} && docker build $BUILD_ARGS -f ${{ inputs.dockerfile }} --cache-from $IMAGE_TAG_1 -t $IMAGE_TAG_1 .)
else
(cd ${{ inputs.image_source_directory }} && docker build $BUILD_ARGS -f ${{ inputs.dockerfile }} -t $IMAGE_TAG_1 .)
fi
docker push $IMAGE_TAG_1
if [ '${{ inputs.image_version_2 }}' != '' ]; then
export IMAGE_TAG_2="${IMAGE_TAG_URL_PREFIX}${{ inputs.image_name }}:${{ inputs.image_version_2 }}${{ inputs.image_version_suffix }}"
docker tag $IMAGE_TAG_1 $IMAGE_TAG_2
docker push $IMAGE_TAG_2
fi
222 changes: 218 additions & 4 deletions .github/workflows/build_and_publish_all_images.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,224 @@
name: Stub
name: Build & publish all images

on: workflow_call
on:
workflow_call:
inputs:
image_version_1:
description: A version for all image tags, such as "foo" in "ghcr.io/user/repo/image:foo"
required: true
type: string
image_version_2:
description: Another version for all image tags, such as "bar" in "ghcr.io/user/repo/image:bar"
required: false
type: string

env:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_username: $GITHUB_ACTOR

jobs:

stub:
app_proxy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: app-proxy
image_source_directory: images/app-proxy
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

app_streaming_bionic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
dockerfile: Dockerfile.bionic
github_token: $github_token
github_username: $github_username
image_name: app-streaming
image_source_directory: images/app-streaming
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}
image_version_suffix: -bionic

app_streaming_buster:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: app-streaming
image_source_directory: images/app-streaming
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}
image_version_suffix: -buster

app_streaming_focal:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
dockerfile: Dockerfile.focal
github_token: $github_token
github_username: $github_username
image_name: app-streaming
image_source_directory: images/app-streaming
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}
image_version_suffix: -focal

app_streaming_focal_cuda:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
dockerfile: Dockerfile.focal-cuda
github_token: $github_token
github_username: $github_username
image_name: app-streaming
image_source_directory: images/app-streaming
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}
image_version_suffix: -focal-cuda

desktop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: desktop
image_source_directory: images/desktop
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

pulseaudio:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: pulseaudio
image_source_directory: images/pulseaudio
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

squid_proxy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: squid-proxy
image_source_directory: images/squid-proxy
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

tinyfilemanager:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: tinyfilemanager
image_source_directory: images/tinyfilemanager
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

uinput_device_plugin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: uinput-device-plugin
image_source_directory: images/uinput-device-plugin
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

watchdog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: watchdog
image_source_directory: images/watchdog
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

webrtc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: webrtc
image_source_directory: images/webrtc
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

xpra:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: xpra
image_source_directory: images/xpra
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}

xserver:
runs-on: ubuntu-latest
steps:
- run: echo 'stub'
- uses: actions/checkout@v2
- name: Build & publish image
uses: ./.github/actions/build_and_publish_image
with:
github_token: $github_token
github_username: $github_username
image_name: xserver
image_source_directory: images/xserver
image_version_1: ${{ inputs.image_version_1 }}
image_version_2: ${{ inputs.image_version_2 }}
Loading

0 comments on commit 61a4a6e

Please sign in to comment.