GitHub CI #505
This file contains hidden or 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: GitHub CI | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: 0 20 * * * | |
| jobs: | |
| generate-jobs: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install dependencies | |
| run: | | |
| sudo wget -q -O /usr/local/bin/bashbrew https://github.com/docker-library/bashbrew/releases/latest/download/bashbrew-amd64 | |
| sudo chmod +x /usr/local/bin/bashbrew | |
| sudo chown root:root /usr/local/bin/bashbrew | |
| - name: Check for changes | |
| id: set-matrix | |
| run: | | |
| declare -a changed_apps | |
| apps=("golang" "node" "python" "redis" "postgres" "mariadb" "nextcloud" "nginx" "php") | |
| commit_message="build(app): bump app to latest" | |
| for app in "${apps[@]}"; do | |
| pushd $app | |
| chmod +x *.sh | |
| ./update.sh | |
| popd | |
| if git status --porcelain -- $app | grep 'M'; then | |
| changed_apps+=("$app") | |
| fi | |
| done | |
| if [ ${#changed_apps[@]} -eq 0 ]; then | |
| echo 'matrix={"include":[]}' >> $GITHUB_OUTPUT | |
| else | |
| json_array=$(printf '%s\n' "${changed_apps[@]}" | jq -R . | jq -s '. | map({"app":.})' | jq -c .) | |
| echo "matrix={\"include\":${json_array}}" >> $GITHUB_OUTPUT | |
| fi | |
| git status | |
| git config --global user.name "${GITHUB_ACTOR}" | |
| git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
| git commit -am "${commit_message}" || exit 0 | |
| git push origin HEAD:main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| trigger-workflows: | |
| needs: generate-jobs | |
| if: ${{ fromJson(needs.generate-jobs.outputs.matrix).include[0] }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.generate-jobs.outputs.matrix) }} | |
| steps: | |
| - name: Trigger workflow | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: '${{ matrix.app }}.yml', | |
| ref: 'main' | |
| }) |