AutoCompiler OpenWrt Packages #158
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (C) 2024 nosignals | |
# | |
name: AutoCompiler OpenWrt Packages | |
on: | |
workflow_run: | |
workflows: ["Auto Sync App"] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/workflows/**' | |
- 'README.md' | |
workflow_dispatch: | |
inputs: | |
compile_pkg: | |
description: 'Compile packages (default : all packages on list_packages.txt)' | |
required: false | |
default: '' | |
type: string | |
verbose: | |
description: 'Verbose (default : 0)' | |
required: false | |
default: '0' | |
type: string | |
without_pages: | |
description: 'Dont deploy pages' | |
required: true | |
default: false | |
type: boolean | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build_ipk: | |
permissions: | |
contents: write | |
name: AutoCompiler | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
release: | |
- 22.03.5 | |
- 23.05.2 | |
arch: | |
- x86_64 | |
- mips_24kc | |
- mipsel_24kc | |
- arm_cortex-a7_neon-vfpv4 | |
- aarch64_cortex-a53 | |
- aarch64_cortex-a72 | |
- aarch64_generic | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Reading Package | |
if: inputs.compile_pkg == '' | |
id: list_package | |
uses: jaywcjlove/github-action-read-file@main | |
with: | |
branch: main | |
path: list_packages.txt | |
- name: List Compiled Packages | |
run: echo "Compiled Packages | ${{ steps.list_package.outputs.content }} ${{ inputs.compile_pkg }}" | |
- name: Creating Directory | |
run: mkdir artifacts | |
- name: Building Package | |
uses: nosignals/gh-action-sdk@main | |
env: | |
ARCH: ${{ matrix.arch }}-${{ matrix.release }} | |
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts | |
FEED_DIR: ${{ github.workspace }}/feeds | |
PACKAGES: ${{ steps.list_package.outputs.content}} ${{ inputs.compile_pkg }} | |
INDEX: 1 | |
V: ${{ inputs.verbose }} | |
- name: Delivering Package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: openwrt_${{ matrix.release }}_${{ matrix.arch }} | |
path: ${{ github.workspace }}/artifacts/bin/packages/${{ matrix.arch }}/* | |
push_packages: | |
needs: build_ipk | |
name: Push Packages | |
permissions: | |
contents: write # To push a branch | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: 'gh-pages' | |
lfs: false | |
submodules: false | |
- name: Download temporary artifact | |
uses: actions/download-artifact@v3 | |
- name: Moving artifact to releases | |
shell: bash | |
run: | | |
# rm -rf releases/* | |
mkdir -p releases 2>/dev/null | |
version=( 22.03.5 23.05.2 ) | |
archi=( x86_64 mips_24kc mipsel_24kc arm_cortex-a7_neon-vfpv4 aarch64_cortex-a53 aarch64_cortex-a72 aarch64_generic ) | |
for vr in ${version[*]} | |
do | |
vers=$(echo $vr | sed 's/..$//') | |
for arc in ${archi[*]} | |
do | |
rm -rf releases/$vers/packages/$arc | |
mkdir -p releases/$vers/packages/$arc | |
cp -rf openwrt_$vr\_$arc/* releases/$vers/packages/$arc | |
rm -rf releases/$vers/packages/$arc/routing releases/$vers/packages/$arc/telephony | |
done | |
done | |
rm -rf openwrt_* 2>/dev/null | |
- name: Display structure files | |
working-directory: releases | |
run: ls -R | |
- name: Commit and push Packages | |
env: | |
Branch: gh-pages | |
run: | | |
git config --local user.name "GitHub Action" | |
git config --local user.email "[email protected]" | |
git add . | |
git commit -m "Update Packages" | |
git push | |
build_pages: | |
needs: push_packages | |
if: inputs.without_pages == 0 && !cancelled() | |
name: Building pages | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: 'gh-pages' | |
lfs: true | |
submodules: true | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 # v1.127.0 | |
with: | |
ruby-version: '3.1' | |
bundler-cache: true | |
cache-version: 0 | |
- name: prenodes | |
env: | |
SERVER_HOME: releases | |
run: ./prenodes.sh | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
- name: Build with Jekyll | |
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" | |
env: | |
JEKYLL_ENV: production | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build_pages | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
clear_artifact: | |
needs: push_packages | |
name: Clearing Artifact | |
permissions: | |
actions: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
retain_days: 5 | |
keep_minimum_runs: 2 | |