Sync code #76
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 code | |
on: | |
schedule: | |
- cron: '0 1 * * *' | |
push: | |
paths: | |
- '.github/workflows/scripts/**' | |
- '.github/workflows/build-*' | |
- main.sh | |
workflow_dispatch: | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
outputs: | |
branchs: ${{ steps.set_env.outputs.branchs }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set env | |
id: set_env | |
run: | | |
branchs=main | |
branchs+=$(echo;git ls-remote origin | sed -n 's|.*\(openwrt-*\)|\1|p' | xargs) | |
JSON='[' | |
FIRST=1 | |
for BRANCH in $branchs; do | |
TUPLE='"'"$(echo $BRANCH | cut -d "/" -f 1)"'"' | |
[[ $FIRST -ne 1 ]] && JSON="$JSON"',' | |
JSON="$JSON""$TUPLE" | |
FIRST=0 | |
done | |
JSON="$JSON"']' | |
echo -e "\n---- branchs ----\n" | |
echo "$JSON" | |
echo -e "\n---- branchs ----\n" | |
echo "branchs=$JSON" >> $GITHUB_OUTPUT | |
check: | |
name: Check | |
needs: [setup] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
branch: ${{fromJson(needs.setup.outputs.branchs)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ matrix.branch }} | |
token: ${{ secrets.PAT }} | |
- name: Sync main | |
if: ${{ matrix.branch != 'main' }} | |
run: | | |
git clone ${{ github.server_url }}/${{ github.repository }} feeds/main | |
mkdir -p .github/workflows/ | |
cp -rfv feeds/main/.github/workflows/scripts/ feeds/main/.github/workflows/build-* .github/workflows/ | |
cp -rfv feeds/main/main.sh . | |
- name: Determine update | |
run: bash main.sh update | |
- name: Determine changes | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
if [ -n "$(git status -s)" ];then | |
git pull && git add . && git commit -m "CI: sync code" && git push | |
fi |