name: Refresh on: schedule: - cron: '0 0 * * 0' push: branches: - 'automation' - 'automation-test' jobs: update: runs-on: ubuntu-latest name: "Update Mirror" steps: - uses: actions/checkout@v2 name: "Checkout" - name: "Configure" shell: bash run: | git config --global user.name 'GitHub Actions' git config --global user.email 'xaymar@users.noreply.github.com' git config pull.ff only git config pull.rebase true - name: "Remotes" shell: bash run: | git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} git remote add -f --tags remote https://git.ffmpeg.org/ffmpeg.git git fetch --all - name: "Synchronize with Remote and trigger Builds" if: ${{ github.event_name == 'schedule' }} shell: bash run: | declare -a BRANCHES BRANCHES[${#BRANCHES[@]}]="master" BRANCHES[${#BRANCHES[@]}]="release/4.4" BRANCHES[${#BRANCHES[@]}]="release/4.3" BRANCHES[${#BRANCHES[@]}]="release/4.2" BRANCHES[${#BRANCHES[@]}]="release/4.1" BRANCHES[${#BRANCHES[@]}]="release/4.0" BRANCHES[${#BRANCHES[@]}]="release/3.4" BRANCHES[${#BRANCHES[@]}]="release/3.3" BRANCHES[${#BRANCHES[@]}]="release/3.2" BRANCHES[${#BRANCHES[@]}]="release/3.1" BRANCHES[${#BRANCHES[@]}]="release/3.0" BRANCHES[${#BRANCHES[@]}]="release/2.8" BRANCHES[${#BRANCHES[@]}]="release/2.7" BRANCHES[${#BRANCHES[@]}]="release/2.6" BRANCHES[${#BRANCHES[@]}]="release/2.5" BRANCHES[${#BRANCHES[@]}]="release/2.4" BRANCHES[${#BRANCHES[@]}]="release/2.3" BRANCHES[${#BRANCHES[@]}]="release/2.2" BRANCHES[${#BRANCHES[@]}]="release/2.1" BRANCHES[${#BRANCHES[@]}]="release/2.0" BRANCHES[${#BRANCHES[@]}]="release/1.2" BRANCHES[${#BRANCHES[@]}]="release/1.1" BRANCHES[${#BRANCHES[@]}]="release/1.0" BRANCHES[${#BRANCHES[@]}]="release/0.11" BRANCHES[${#BRANCHES[@]}]="release/0.10" BRANCHES[${#BRANCHES[@]}]="release/0.9" BRANCHES[${#BRANCHES[@]}]="release/0.8" BRANCHES[${#BRANCHES[@]}]="release/0.7" BRANCHES[${#BRANCHES[@]}]="release/0.6" BRANCHES[${#BRANCHES[@]}]="release/0.5" BRANCHES[${#BRANCHES[@]}]="oldabi" echo "Testing branches for differences..." for d in ${BRANCHES[@]}; do BRANCH_REQUIRES_UPDATE=false if ! git branch -a | grep origin/${d}; then echo " '${d}' is missing, creating..." git checkout -b ${d} remote/${d} BRANCH_REQUIRES_UPDATE=true elif ! git diff -s --exit-code origin/${d} remote/${d}; then echo " '${d}' is out of date, updating..." git checkout -b ${d} origin/${d} BRANCH_REQUIRES_UPDATE=true fi if ${BRANCH_REQUIRES_UPDATE}; then git push --follow-tags --set-upstream origin ${d} curl \ -X POST \ -H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ -d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\"}}" \ "https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches" fi done - name: "Only trigger build on manual push" if: ${{ github.event_name == 'push' }} shell: bash run: | declare -a BRANCHES BRANCHES[${#BRANCHES[@]}]="master" BRANCHES[${#BRANCHES[@]}]="release/4.4" BRANCHES[${#BRANCHES[@]}]="release/3.4" for d in ${BRANCHES[@]}; do curl \ -X POST \ -H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ -d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\"}}" \ "https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches" done