Skip to content

Commit

Permalink
add self-hosted ci
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Oct 11, 2023
1 parent 3383eb9 commit a92672e
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build-system-image-self-hosted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build ChimeraOS image self-hosted
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
workflow_call:
inputs:
postfix:
type: string
description: Postfix used in release.
default: ''

jobs:
build-system-image:
runs-on: self-hosted
permissions:
contents: write
outputs:
version: ${{ steps.build_image.outputs.version }}
display_name: ${{ steps.build_image.outputs.display_name }}
display_version: ${{ steps.build_image.outputs.display_version }}
image_filename: ${{ steps.build_image.outputs.image_filename }}
steps:
- uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- uses: actions/download-artifact@v3
with:
name: AUR-packages
path: aur-pkgs/
- uses: actions/download-artifact@v3
with:
name: Packages
path: pkgs/
- name: Build system image
id: build_image
run: |
docker pull ${{ steps.meta.outputs.tags }}
docker run -u root --rm --entrypoint=/workdir/build-image.sh -v $(pwd):/workdir -v $(pwd)/output:/output -v $GITHUB_OUTPUT:$GITHUB_OUTPUT -e "GITHUB_OUTPUT=$GITHUB_OUTPUT" --privileged=true ${{ steps.meta.outputs.tags }} $(echo ${GITHUB_SHA} | cut -c1-7)
echo -e "$(docker inspect --format='{{index .RepoDigests 0}}' ${{ steps.meta.outputs.tags }})" > output/container.txt
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.build_image.outputs.version }}
target_commitish: ${{ github.sha }}
name: ${{ steps.build_image.outputs.display_name }} ${{ steps.build_image.outputs.display_version }} ${{ inputs.postfix }}
draft: false
prerelease: true
fail_on_unmatched_files: true
files: |
output/${{ steps.build_image.outputs.image_filename }}
output/build_info.txt
output/sha256sum.txt
output/container.txt
96 changes: 96 additions & 0 deletions .github/workflows/main-self-hosted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: System image build self-hosted

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches:
- master
- dev
workflow_dispatch:

jobs:
build-docker-image:
name: Build and publish docker container
uses: ./.github/workflows/build-builder.yml

list-pkgbuilds:
name: List Packages
runs-on: ubuntu-latest
outputs:
aur-pkgs: ${{ steps.set-aur-pkgs.outputs.matrix }}
pkgs: ${{ steps.set-pkgs.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-aur-pkgs
run: source ./manifest ; echo "matrix=$(echo ${AUR_PACKAGES} | jq -R -s -c 'split(" ")')" >> $GITHUB_OUTPUT
shell: bash
- id: set-pkgs
run: echo "matrix=$(ls -d pkgs/*/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
shell: bash

aur-pkgbuild:
needs:
- build-docker-image
- list-pkgbuilds
name: Build AUR package
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
package: ${{ fromJson(needs.list-pkgbuilds.outputs.aur-pkgs) }}
steps:
- uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build packages
run: |
docker pull ${{ steps.meta.outputs.tags }}
docker run --rm -v $(pwd):/workdir --entrypoint=/workdir/aur-pkgs/build-aur-package.sh ${{ steps.meta.outputs.tags }} ${{ matrix.package }}
- name: Upload Package Archives
uses: actions/upload-artifact@v3
with:
name: AUR-packages
path: aur-pkgs/*.pkg.tar*

pkgbuild:
needs:
- build-docker-image
- list-pkgbuilds
name: Build package
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
package: ${{ fromJson(needs.list-pkgbuilds.outputs.pkgs) }}
steps:
- uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build packages
run: |
docker pull ${{ steps.meta.outputs.tags }}
docker run --rm -v $(pwd):/workdir --entrypoint=/workdir/pkgs/build-package.sh ${{ steps.meta.outputs.tags }} ${{ matrix.package }}
- name: Upload Package Archives
uses: actions/upload-artifact@v3
with:
name: Packages
path: pkgs/*.pkg.tar*

build:
needs:
- build-docker-image
- aur-pkgbuild
- pkgbuild
name: Build ChimeraOS UNSTABLE image
uses: ./.github/workflows/build-system-image-self-hosted.yml
with:
postfix: "[UNSTABLE]"

0 comments on commit a92672e

Please sign in to comment.