Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
philn committed Oct 16, 2024
1 parent ded44bb commit 0d53ee6
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: build
on:
push:
branches: [ f40 ]
paths-ignore: [ README.md, justfile]
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-22.04
permissions: write-all
steps:
- name: Install Build Dependencies
run: |
sudo apt-get update && sudo apt-get -y install fuse-overlayfs podman
- name: Install Just
uses: extractions/setup-just@v2

- name: Checkout repo
uses: actions/checkout@v4

- name: Build image
run: |
just build
- name: Deploy image
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io --username=${GITHUB_REPOSITORY_OWNER} --password-stdin
just push ghcr.io/${GITHUB_REPOSITORY_OWNER}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Installation

As this image has been pushed to my dockerhub, you can download it:
As this image has been pushed to my ghcr.io registry, you can download it:

```sh
$ toolbox create -c gst-dev-f40 --image docker.io/philn2/gst-dev:f40
$ ./gst-bx -u --image ghcr.io/philn
```

# Local build

If you prefer to build it yourself:

```sh
$ podman build -t gst-dev:f40 .
$ toolbox create -c gst-dev-f40 --image localhost/gst-dev:f40
$ just build
$ ./gst-bx -u
```
48 changes: 48 additions & 0 deletions gst-bx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3

import os
import sys
import argparse
import subprocess

CONTAINER_PATH="localhost"
IMAGE_NAME="gst-dev-f"
CONTAINER_VERSION=40

def run(*args, capture_output=True):
cmdline = args
print("Running %s" % " ".join(cmdline))
proc = subprocess.run(cmdline, capture_output=capture_output, text=True)
if proc.returncode != 0:
raise Exception(proc.returncode)
if capture_output:
return proc.stdout.strip()

def update(namespace):
try:
run('podman', 'stop', namespace.name)
except:
pass
run('toolbox', 'rm', namespace.name)
run('toolbox', 'create', '-y', '-c', namespace.name, '--image', f'{namespace.image}/gst-dev:f{namespace.version}', capture_output=False)

def main(args):
parser = argparse.ArgumentParser(prog="gst-bx", add_help=True)
general = parser.add_argument_group("General")
general.add_argument("-n", "--name", dest="name", default=f"{IMAGE_NAME}{CONTAINER_VERSION}",
help=f"Toolbox name (default: {IMAGE_NAME}{CONTAINER_VERSION})")
general.add_argument("-v", "--version", dest="version", default=CONTAINER_VERSION,
help=f"Container version (default: {CONTAINER_VERSION})")
general.add_argument("-i", "--image", dest="image", default=CONTAINER_PATH,
help=f"Container image path (default: {CONTAINER_PATH})")
general.add_argument("-u", "--update", dest="update", action="store_true", help="Update the thing")

namespace = parser.parse_args(args=args)

if namespace.update:
update(namespace)

return 0

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
22 changes: 22 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

tag := "gst-dev:f40"
default_registry := "ghcr.io/philn"
default_archive := "gst-dev-container.tar"

build:
podman pull registry.fedoraproject.org/fedora-toolbox:40
podman build -t {{tag}} .

push registry=default_registry:
podman push {{tag}} {{registry}}/{{tag}}

pull registry=default_registry:
podman pull {{registry}}/{{tag}}
./gst-bx -u --image {{registry}}
podman image prune -a -f

export archive=default_archive: build
podman save --format=oci-archive -o {{archive}} {{tag}}

import archive=default_archive:
podman load < {{archive}}

0 comments on commit 0d53ee6

Please sign in to comment.