Skip to content

Commit

Permalink
use github actions inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
devbis committed Oct 3, 2024
1 parent e578f64 commit c68c5e6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build-openwrt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ env:
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
TMATE_ENCRYPT_PASSWORD: ${{secrets.TMATE_ENCRYPT_PASSWORD}}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
OPT_UPDATE_FEEDS: 1
#OPT_REBUILD: 1
OPT_UPDATE_FEEDS: true

name: Build OpenWrt

on:
deployment:
repository_dispatch:
workflow_dispatch:
env:
OPT_DEBUG: 1
inputs:
OPT_REBUILD:
description: 'Rebuild from Scratch'
required: false
type: boolean
pull_request:
push:
paths:
Expand Down Expand Up @@ -91,6 +93,7 @@ jobs:
HOST_WORK_DIR: ${{github.workspace}}
BUILD_MODE: ${{matrix.mode}}
BUILD_TARGET: ${{matrix.target}}
OPT_REBUILD: ${{ inputs.OPT_REBUILD }}

steps:
- name: Checkout
Expand Down
8 changes: 4 additions & 4 deletions scripts/cisteps/build-openwrt/05-check_builders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ source "${HOST_WORK_DIR}/scripts/host/docker.sh"
# shellcheck disable=SC1090
source "${HOST_WORK_DIR}/scripts/lib/gaction.sh"

if [ "x${OPT_REBUILD}" != "x1" ]; then
if [ "x${OPT_REBUILD}" != "xtrue" ]; then
# temporarily disable failure guarder
set +eo pipefail
docker buildx imagetools inspect "${BUILDER_IMAGE_ID_INC}" > /dev/null 2>&1
docker buildx imagetools inspect "${BUILDER_IMAGE_ID_INC}" > /dev/null 2>&1
builder_inc_ret_val=$?
set -eo pipefail

Expand All @@ -21,15 +21,15 @@ if [ "x${OPT_REBUILD}" != "x1" ]; then
set -eo pipefail
if [ "x${builder_base_ret_val}" != "x0" ]; then
echo "Base builder '${BUILDER_IMAGE_ID_BASE}' does not exist, creating one"
OPT_REBUILD=1
OPT_REBUILD=true
else
echo "Creating incremental builder '${BUILDER_IMAGE_ID_INC}' from base builder '${BUILDER_IMAGE_ID_BASE}'"
create_remote_tag_alias "${BUILDER_IMAGE_ID_BASE}" "${BUILDER_IMAGE_ID_INC}"
fi
fi
fi

if [ "x${OPT_REBUILD}" = "x1" ]; then
if [ "x${OPT_REBUILD}" = "xtrue" ]; then
echo "Re-creating base builder '${BUILDER_IMAGE_ID_BASE}'"
fi
_set_env OPT_REBUILD
2 changes: 1 addition & 1 deletion scripts/cisteps/build-openwrt/06-get_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source "${HOST_WORK_DIR}/scripts/host/docker.sh"

# 'eval' is to correctly parse quotes
eval "declare -a MOUNT_OPTS=( ${BUILDER_MOUNT_OPTS} )"
if [ "x${OPT_REBUILD}" != "x1" ]; then
if [ "x${OPT_REBUILD}" != "xtrue" ]; then
pull_image "${BUILDER_IMAGE_ID_INC}"
squash_image_when_necessary "${BUILDER_IMAGE_ID_INC}"
docker run -d -t --name "${BUILDER_CONTAINER_ID}" "${MOUNT_OPTS[@]}" "${BUILDER_IMAGE_ID_INC}"
Expand Down
4 changes: 2 additions & 2 deletions scripts/cisteps/build-openwrt/13-upload_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ docker commit -a "tete1030/openwrt-fastbuild-actions" -m "Building at $(date)" "
docker container rm -fv "${BUILDER_CONTAINER_ID}"
docker container prune -f
docker system prune -f --volumes
if [ "x${OPT_REBUILD}" != 'x1' ]; then
if [ "x${OPT_REBUILD}" != 'xtrue' ]; then
squash_image_when_necessary "${BUILDER_IMAGE_ID_INC}"
fi
docker push "${BUILDER_IMAGE_ID_INC}"
if [ "x${OPT_REBUILD}" = "x1" ]; then
if [ "x${OPT_REBUILD}" = "xtrue" ]; then
create_remote_tag_alias "${BUILDER_IMAGE_ID_INC}" "${BUILDER_IMAGE_ID_BASE}"
fi
8 changes: 4 additions & 4 deletions scripts/update_feeds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if [ -f "${OPENWRT_CUR_DIR}/feeds.conf" ]; then
cp "${OPENWRT_CUR_DIR}/feeds.conf" "${BUILDER_TMP_DIR}/feeds.conf.bak"
fi

if [ "x${OPENWRT_CUR_DIR}" != "x${OPENWRT_COMPILE_DIR}" ] && [ "x${OPT_UPDATE_FEEDS}" != "x1" ]; then
if [ "x${OPENWRT_CUR_DIR}" != "x${OPENWRT_COMPILE_DIR}" ] && [ "x${OPT_UPDATE_FEEDS}" != "xtrue" ]; then
# Use previous feeds
(
set +eo pipefail
Expand All @@ -52,7 +52,7 @@ fi
)

if [ -f "${BUILDER_TMP_DIR}/feeds.conf.bak" ]; then
mv "${BUILDER_TMP_DIR}/feeds.conf.bak" "${OPENWRT_CUR_DIR}/feeds.conf"
mv "${BUILDER_TMP_DIR}/feeds.conf.bak" "${OPENWRT_CUR_DIR}/feeds.conf"
fi

PACKAGE_DEFAULT_ROOT="package/openwrt-packages"
Expand Down Expand Up @@ -161,7 +161,7 @@ install_package() {
echo "install_package: installing custom package: ${ALL_PARAMS}"
if [ -z "${PACKAGE_SUBDIR}" ]; then
# Use previous git to preserve version
if [ "x${full_cur_package_path}" != "x${full_compile_package_path}" ] && [ -d "${full_compile_package_path}/.git" ] && [ "x${OPT_UPDATE_FEEDS}" != "x1" ]; then
if [ "x${full_cur_package_path}" != "x${full_compile_package_path}" ] && [ -d "${full_compile_package_path}/.git" ] && [ "x${OPT_UPDATE_FEEDS}" != "xtrue" ]; then
git clone "${full_compile_package_path}" "${full_cur_package_path}"
git -C "${full_cur_package_path}" remote set-url origin "${PACKAGE_URL}"
git -C "${full_cur_package_path}" fetch
Expand All @@ -178,7 +178,7 @@ install_package() {
echo "install_package: using subdir strategy"
# when using SUBDIR
# Use previous git to preserve version
if [ "x${full_cur_package_path}" != "x${full_compile_package_path}" ] && [ -d "${full_compile_package_path}/.git" ] && [ "x${OPT_UPDATE_FEEDS}" != "x1" ]; then
if [ "x${full_cur_package_path}" != "x${full_compile_package_path}" ] && [ -d "${full_compile_package_path}/.git" ] && [ "x${OPT_UPDATE_FEEDS}" != "xtrue" ]; then
git clone "${full_compile_package_path}" "${full_cur_package_path}"
if [ -n "${PACKAGE_REF}" ]; then
echo "install_package: PACKAGE_REF is not respected as 'update_feeds' is not enabled"
Expand Down

0 comments on commit c68c5e6

Please sign in to comment.