Skip to content

defconfig

defconfig #29

Workflow file for this run

#
# Copyright (c) 2022-2024 SMALLPROGRAM <https://github.com/smallprogram/OpenWrtAction>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/smallprogram/OpenWrtAction
# Description: Build OpenWrt using GitHub Actions
#
name: defconfig
on:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
is_display_detailed:
description: 'Whether to display detailed information about compilation'
required: false
default: 'false'
is_single_threaded:
description: 'Whether single-threaded compilation'
required: false
default: 'false'
# schedule:
# - cron: 0 */8 * * *
env:
MAKE_DEFCONFIG_SH: compile_script/step01_make_defconfig.sh
GENERATE_RELEASE_TAG_SH: compile_script/step02_generate_release_tag.sh
GENERATE_GIT_LOG_SH: compile_script/step03_generate_git_log.sh
UPDATE_GIT_LOG_SH: compile_script/step06_update_git_log.sh
ORGANIZE_TAG_SH: compile_script/step07_organize_tag.sh
PLATFORMS_SH: compile_script/platforms.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_ARTIFACT: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
job_init:
runs-on: ubuntu-latest
name: Init
outputs:
output_release_tag: ${{ steps.gen_release_tag.outputs.release_tag }}
platforms: ${{ steps.read-platforms.outputs.matrix }}
platforms_source: ${{ steps.read-platforms.outputs.source_matrix_json }}
steps:
- name: Generate Tag Name
id: gen_release_tag
run: |
echo "release_tag=multi-platform_$(date +"%Y.%m.%d_%H.%M.%S")" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read Platforms From File
id: read-platforms
run: |
bash $PLATFORMS_SH
job_source_init:
needs: job_init
runs-on: ${{ matrix.value.OS }}
name: Source-Init-${{ matrix.source_code_platform }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.job_init.outputs.platforms_source) }}
steps:
- name: Init System
id: init
run: |
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown -R $USER:$GROUPS /workdir
cd /workdir
sudo mkdir -p output
sudo chown -R $USER:$GROUPS /workdir/output
ln -sf /workdir/output $GITHUB_WORKSPACE/output
df -hT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Clone Source Code
working-directory: /workdir
run: |
git clone -b ${{matrix.value.REPO_BRANCH}} --single-branch ${{ matrix.value.REPO_URL }} openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Load Custom Feeds
run: |
# [ -e $FEEDS_CONF ] && cp -r ${{ matrix.value.FEEDS_CONF }} openwrt/feeds.conf.default
chmod +x ${{ matrix.value.DIY_P1_SH }}
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P1_SH }}
- name: Update Feeds
run: cd openwrt && ./scripts/feeds update -a
- name: Install Feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Pull the latest changes and Create temporary branch
run: |
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout -b temp-${{ matrix.source_code_platform }}
- name: Make Defconfig Custom Configuration
run: |
chmod +x ${{ matrix.value.DIY_P2_SH }}
chmod +x $MAKE_DEFCONFIG_SH
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P2_SH }}
$GITHUB_WORKSPACE/$MAKE_DEFCONFIG_SH "${{ matrix.source_code_platform }}" "${{ matrix.value.CONFIGS }}"
- name: Merge and push changes with "theirs" strategy
run: |
git checkout temp-${{ matrix.source_code_platform }}
git add .
if ! git diff --cached --quiet; then
git config user.name "smallprogram"
git config user.email "smallprogram@foxmail.com"
git commit -m "Auto update for ${{ matrix.source_code_platform }} configuration"
git checkout ${{ github.ref_name }}
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout temp-${{ matrix.source_code_platform }}
git merge origin/${{ github.ref_name }} --no-ff --strategy-option theirs --no-edit || {
echo "Merge conflict in temp branch, please resolve manually."
exit 100
}
git checkout ${{ github.ref_name }}
git merge temp-${{ matrix.source_code_platform }} --strategy-option theirs --no-edit
git push origin ${{ github.ref_name }} --force
git branch -d temp-${{ matrix.source_code_platform }} || echo "Local temp-${{ matrix.source_code_platform }} not found"
git push origin --delete temp-${{ matrix.source_code_platform }} || echo "Remote temp-${{ matrix.source_code_platform }} not found"
else
echo "No changes to commit."
fi