diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..80e8db4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +--- +name: Build Docker Image + +on: [push, pull_request] + +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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4174115 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +--- +name: "Lint" + +on: [push, pull_request] + +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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8649415 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b74634f --- /dev/null +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..c7d0dc3 --- /dev/null +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f341021 --- /dev/null +++ b/entrypoint.sh @@ -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"