Sync upstream #10
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
name: Sync upstream | |
on: | |
# push: | |
# paths: | |
# - '.github/workflows/Sync-upstream.yml' | |
# - 'diy/**' | |
schedule: | |
- cron: 30 5 * * * | |
watch: | |
types: started | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
ssh: | |
description: 'SSH connection to Actions' | |
required: false | |
default: 'false' | |
jobs: | |
build: | |
if: github.event.repository.owner.id == github.event.sender.id || ! github.event.sender.id | |
runs-on: Ubuntu-20.04 | |
name: Update ${{matrix.target}} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [main] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Initialization environment | |
run : | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
- name: Clone packages | |
run: | | |
cd $GITHUB_WORKSPACE | |
git clone -b ${{matrix.target}} https://github.com/fichenx/Actions-OpenWrt.git ${{matrix.target}} | |
cd ${{matrix.target}} | |
#git rm -r --cache * >/dev/null 2>&1 & | |
#rm -rf `find ./* -maxdepth 0 -type d ! -name "diy"` >/dev/null 2>&1 | |
rm -rf general | |
rm -rf PATCH | |
rm -rf sh/breakings_diy-part2.sh | |
git clone --depth 1 --filter=blob:none --no-checkout https://github.com/breakings/OpenWrt temp && cd temp && git checkout main -- general PATCH diy-part2.sh && cd .. && mv -n temp/general temp/PATCH ./ && mv -n temp/diy-part2.sh sh/breakings_diy-part2.sh ; rm -rf temp | |
- name: Upload package | |
env: | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
run: | | |
[ -e $GITHUB_WORKSPACE/LICENSE ] && cp $GITHUB_WORKSPACE/LICENSE $GITHUB_WORKSPACE/${{matrix.target}} | |
[ -e $GITHUB_WORKSPACE/README.md ] && cp $GITHUB_WORKSPACE/README.md $GITHUB_WORKSPACE/${{matrix.target}} | |
cd $GITHUB_WORKSPACE/${{matrix.target}} | |
git add . | |
git commit -am "update $(date +%Y-%m-%d" "%H:%M:%S)" | |
git push --quiet "https://${{ secrets.REPO_TOKEN }}@github.com/fichenx/Actions-OpenWrt.git" HEAD:${{matrix.target}} | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@main | |
with: | |
retain_days: 1 | |
keep_minimum_runs: 3 |