From c68c5e66955549c9cdfa0dca7f1c085ffff59346 Mon Sep 17 00:00:00 2001 From: Ivan Belokobylskiy Date: Thu, 3 Oct 2024 10:55:11 +0300 Subject: [PATCH] use github actions inputs --- .github/workflows/build-openwrt.yml | 11 +++++++---- scripts/cisteps/build-openwrt/05-check_builders.sh | 8 ++++---- scripts/cisteps/build-openwrt/06-get_builder.sh | 2 +- scripts/cisteps/build-openwrt/13-upload_builder.sh | 4 ++-- scripts/update_feeds.sh | 8 ++++---- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-openwrt.yml b/.github/workflows/build-openwrt.yml index 3b0b31f0..ffc018e2 100644 --- a/.github/workflows/build-openwrt.yml +++ b/.github/workflows/build-openwrt.yml @@ -14,8 +14,7 @@ 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 @@ -23,8 +22,11 @@ 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: @@ -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 diff --git a/scripts/cisteps/build-openwrt/05-check_builders.sh b/scripts/cisteps/build-openwrt/05-check_builders.sh index bdba63f3..3a82bc12 100755 --- a/scripts/cisteps/build-openwrt/05-check_builders.sh +++ b/scripts/cisteps/build-openwrt/05-check_builders.sh @@ -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 @@ -21,7 +21,7 @@ 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}" @@ -29,7 +29,7 @@ if [ "x${OPT_REBUILD}" != "x1" ]; then 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 diff --git a/scripts/cisteps/build-openwrt/06-get_builder.sh b/scripts/cisteps/build-openwrt/06-get_builder.sh index ee89a0f1..4320eccf 100755 --- a/scripts/cisteps/build-openwrt/06-get_builder.sh +++ b/scripts/cisteps/build-openwrt/06-get_builder.sh @@ -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}" diff --git a/scripts/cisteps/build-openwrt/13-upload_builder.sh b/scripts/cisteps/build-openwrt/13-upload_builder.sh index 40405a89..8a5f29a2 100755 --- a/scripts/cisteps/build-openwrt/13-upload_builder.sh +++ b/scripts/cisteps/build-openwrt/13-upload_builder.sh @@ -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 diff --git a/scripts/update_feeds.sh b/scripts/update_feeds.sh index fe26aa84..10be5d3a 100755 --- a/scripts/update_feeds.sh +++ b/scripts/update_feeds.sh @@ -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 @@ -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" @@ -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 @@ -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"