Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Nov 15, 2023
0 parents commit 0213c67
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Build Docker Image

on: [push, pull_request]

Check warning on line 4 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / YAML

4:1 [truthy] truthy value should be one of [false, true]

Check warning on line 4 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / YAML

4:1 [truthy] truthy value should be one of [false, true]

jobs:
build-docker:
name: "Build Docker Image"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
run: |
docker build \
--build-arg CONTAINER \
--build-arg VERSION \
-t sdk \
.
env:
# Utilize matrix with release-versions once available
VERSION: master
shell: bash
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "Lint"

on: [push, pull_request]

Check warning on line 4 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / YAML

4:1 [truthy] truthy value should be one of [false, true]

Check warning on line 4 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / YAML

4:1 [truthy] truthy value should be one of [false, true]

jobs:
lint-yaml:
name: "YAML"
runs-on: ubuntu-22.04
env:
YAML_FILES: |
.github/workflows/build.yml
.github/workflows/lint.yml
action.yml
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y yamllint shellcheck
- name: Validate YAML Files
run: yamllint $YAML_FILES

shellcheck:
name: "Shell Scripts"
runs-on: ubuntu-22.04
env:
SHELL_FILES: entrypoint.sh
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Validate Shell Scripts
run: shellcheck $SHELL_FILES
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARG CONTAINER=ghcr.io/freifunk-gluon/gluon-build
ARG VERSION=master
FROM $CONTAINER:$VERSION

COPY --chmod=0755 entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# action-gluon-build

GitHub Actions action to interact with the Gluon build-framework.

This Action utlizes the `gluon-build` docker container.


## Input

### container-version
#### Description
Container version to use

#### Default
master


### gluon-path
#### Description
Path to Gluon repository

#### Default
true


### site-path:
#### Description
Path to Gluon site-directory

#### Default
Working Directory


### autoremove
#### Description
Remove build-directories after build

#### Default
1

### autoupdater-enabled
#### Description
Autoupdater should be enabled by default

#### Default
0


### autoupdater-branch
#### Description
Default branch for the Autoupdater


### broken
#### Description
Determines if BROKEN devices should be built

#### Default
0


### deprecated
#### Description
Determines if deprecated devices should be built
#### Default
0


### hardware-target
#### Description
Target to build


### make-target
#### Description
Make target to use


### priority
#### Description
Priority indicator for the autoupdater


### release
#### Description
Version string for the release to use
76 changes: 76 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: "Build Gluon"
description: "Build Gluon images using the build-gluon docker container"
inputs:
container-version:
description: 'Container version to use'
default: 'master'
gluon-path:
description: 'Path to Gluon repository'
required: true
site-path:
description: 'Path to Gluon site-directory'
default: ''
autoremove:
description: 'Remove build-directories after build (Default: 1)'
default: 1
autoupdater-enabled:
description: 'Autoupdater should be enabled by default (Default: 0)'
default: 0
autoupdater-branch:
description: 'Default branch for the Autoupdater'
broken:
description: 'Determines if BROKEN devices should be built (Default: 0)'
default: 0
deprecated:
description: 'Determines if deprecated devices should be built (Default: 0)'
default: 0
hardware-target:
description: 'Target to build'
make-target:
description: 'Make target to use'
default: ''
priority:
description: Priority indicator for the autoupdater
release:
description: 'Version string for the release to use'
runs:
using: 'composite'
steps:
- run: |
docker build \
--build-arg CONTAINER \
--build-arg VERSION \
-t sdk \
$GITHUB_ACTION_PATH
env:
VERSION: ${{ inputs.container-version }}
shell: bash
- run: |
docker run --rm \
--user "$(id -u):$(id -g)" \
--env ACTION_MAKE_TARGET \
--env ACTION_GLUON_AUTOREMOVE \
--env ACTION_GLUON_AUTOUPDATER_ENABLED \
--env ACTION_GLUON_AUTOUPDATER_BRANCH \
--env ACTION_GLUON_BROKEN \
--env ACTION_GLUON_DEPRECATED \
--env ACTION_GLUON_PRIORITY \
--env ACTION_GLUON_RELEASE \
--env ACTION_GLUON_TARGET \
--volume "$GITHUB_WORKSPACE/$ACTION_SITE_PATH:/gluon/site-repo" \
--volume "$GITHUB_WORKSPACE/$ACTION_GLUON_PATH:/gluon/gluon-repo" \
sdk
env:
ACTION_GLUON_AUTOREMOVE: ${{ inputs.autoremove }}
ACTION_GLUON_AUTOUPDATER_ENABLED: ${{ inputs.autoupdater-enabled }}
ACTION_GLUON_AUTOUPDATER_BRANCH: ${{ inputs.autoupdater-branch }}
ACTION_GLUON_BROKEN: ${{ inputs.broken }}
ACTION_GLUON_DEPRECATED: ${{ inputs.deprecated }}
ACTION_GLUON_PRIORITY: ${{ inputs.priority }}
ACTION_GLUON_RELEASE: ${{ inputs.release }}
ACTION_GLUON_TARGET: ${{ inputs.hardware-target }}
ACTION_MAKE_TARGET: ${{ inputs.make-target }}
ACTION_GLUON_PATH: ${{ inputs.gluon-path }}
ACTION_SITE_PATH: ${{ inputs.site-path }}
shell: bash
22 changes: 22 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -euxo pipefail

BUILD_THREADS="$(($(nproc) + 1))"

# Determine Gluon Make args
GLUON_MAKE_ARGS=""
[ -n "${ACTION_GLUON_AUTOREMOVE+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} GLUON_AUTOREMOVE=${ACTION_GLUON_AUTOREMOVE}"
[ -n "${ACTION_GLUON_TARGET+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} GLUON_TARGET=${ACTION_GLUON_TARGET}"
[ -n "${ACTION_GLUON_BROKEN+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} BROKEN=${ACTION_GLUON_BROKEN}"
[ -n "${ACTION_GLUON_AUTOUPDATER_BRANCH+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} GLUON_AUTOUPDATER_BRANCH=${ACTION_GLUON_AUTOUPDATER_BRANCH}"
[ -n "${ACTION_GLUON_AUTOUPDATER_ENABLED+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} GLUON_AUTOUPDATER_ENABLED=${ACTION_GLUON_AUTOUPDATER_ENABLED}"
[ -n "${ACTION_GLUON_RELEASE+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} GLUON_RELEASE=${ACTION_GLUON_RELEASE}"
[ -n "${ACTION_GLUON_PRIORITY+x}" ] && GLUON_MAKE_ARGS="${GLUON_MAKE_ARGS} GLUON_PRIORITY=${ACTION_GLUON_PRIORITY}"

echo "Building with ${BUILD_THREADS} threads"
echo "Extra args for build: '${GLUON_MAKE_ARGS}'"

# shellcheck disable=SC2086
# Build
make -C /gluon/gluon-repo $ACTION_MAKE_TARGET $GLUON_MAKE_ARGS GLUON_SITEDIR=/gluon/site-repo V=s "-j$BUILD_THREADS"

0 comments on commit 0213c67

Please sign in to comment.