Skip to content

Repo Dispatcher

Repo Dispatcher #2539

#=================================================
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: P3TERX
# Blog: https://p3terx.com
#=================================================
name: Repo Dispatcher
on:
# push:
# branches:
# - master
schedule:
- cron: 30 15 * * *
watch:
types: started
workflow_dispatch:
inputs:
packages:
description: 'Packages'
required: false
default: ''
env:
REPO_TOKEN: ${{ secrets.TOKEN_kiddin9 }}
TZ: Asia/Shanghai
jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id || ! github.event.sender.id
runs-on: ubuntu-latest
steps:
- name: cancel running workflows
uses: styfle/cancel-workflow-action@main
if: contains(github.event.inputs.packages, ' cw')
with:
workflow_id: all
access_token: ${{ secrets.TOKEN_KIDDIN9 }}
- name: Trigger matrix Update
run: |
gitdate=$(curl -H "Authorization: token ${{ env.REPO_TOKEN }}" -s "https://api.github.com/repos/kiddin9/kwrt-packages/commits?&per_page=1" | jq -r '.[0].commit.committer.date') || true
fpkg="$(echo "${{github.event.action}}" | sed -e 's/\(aarch64_generic\|x86_64\|i386_pentium4\|arm_arm1176jzf-s_vfp\|aarch64_cortex-a72\|aarch64_cortex-a76\|arm_cortex-a7\|arm_cortex-a7_neon-vfpv4\|arm_cortex-a9\|arm_cortex-a15_neon-vfpv4\|arm_cortex-a5_vfpv4\|mipsel_24kc\|mips_24kc\|aarch64_cortex-a53\|arm_xscale\|arm_cortex-a9_vfpv3-d16\| [0-9][0-9.]*\| ssh\| noser\| cw\)//g' | sed -e 's/ //g')"
during="$(echo "${{github.event.inputs.packages}}" | grep -o -E ' [0-9][0-9.]*' | sed -e 's/ //')"
[[ "$fpkg" && ! "$during" ]] || {
[ "$during" ] || during="1.05"
durings=`echo "$during*60*60*24" | bc`
gitdate=$(date -d "$gitdate" +%s)
now=$(date -d "$(date)" +%s)
[ "$during" ] || during="1.05"
durings=`echo "$during*60*60*24" | bc`
if [[ $(expr $gitdate + ${durings%.*}) -lt $now ]]; then
exit;
fi
gitdate=$(curl -H "Authorization: token ${{ env.REPO_TOKEN }}" -s "https://api.github.com/repos/kiddin9/kwrt-packages/actions/runs" | jq -r '.workflow_runs[0].created_at') || true
gitdate=$(date -d "$gitdate" +%s)
now=$(date -d "$(date)" +%s)
if [[ $(expr $gitdate + 180) < $now ]]; then
curl -X POST https://api.github.com/repos/kiddin9/kwrt-packages/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
--data '{"event_type": "update"}'
fi
}
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "x86_64 ${{ github.event.inputs.packages }}", "client_payload": {"target": "x86_64"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "i386_pentium4 ${{ github.event.inputs.packages }}", "client_payload": {"target": "i386_pentium4"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "aarch64_generic ${{ github.event.inputs.packages }}", "client_payload": {"target": "aarch64_generic"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_arm1176jzf-s_vfp ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_arm1176jzf-s_vfp"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_cortex-a5_vfpv4 ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_cortex-a5_vfpv4"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "aarch64_cortex-a72 ${{ github.event.inputs.packages }}", "client_payload": {"target": "aarch64_cortex-a72"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "aarch64_cortex-a53 ${{ github.event.inputs.packages }}", "client_payload": {"target": "aarch64_cortex-a53"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "mipsel_24kc ${{ github.event.inputs.packages }}", "client_payload": {"target": "mipsel_24kc"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "mips_24kc ${{ github.event.inputs.packages }}", "client_payload": {"target": "mips_24kc"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_cortex-a7_neon-vfpv4 ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_cortex-a7_neon-vfpv4"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_cortex-a7 ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_cortex-a7"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_cortex-a9 ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_cortex-a9"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_cortex-a9_vfpv3-d16 ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_cortex-a9_vfpv3-d16"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "arm_cortex-a15_neon-vfpv4 ${{ github.event.inputs.packages }}", "client_payload": {"target": "arm_cortex-a15_neon-vfpv4"}}'
curl \
-X POST https://api.github.com/repos/${{ github.repository }}/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ env.REPO_TOKEN }}" \
-d '{"event_type": "aarch64_cortex-a76 ${{ github.event.inputs.packages }}", "client_payload": {"target": "aarch64_cortex-a76"}}'
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
continue-on-error: true
with:
token: ${{ secrets.TOKEN_KIDDIN9 }}
retain_days: 20
keep_minimum_runs: 1
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
continue-on-error: true
if: env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true' && !cancelled()
with:
keep_latest: 100
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}