feat: automate the update of OS libraries #1
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: Check OS Library Updates | |
| on: | |
| push: | |
| schedule: | |
| - cron: "0 3 * * *" | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| shell: 'bash -Eeuo pipefail -x {0}' | |
| permissions: {} | |
| jobs: | |
| fetch-extensions: | |
| name: Fetch target extensions | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| extensions: ${{ steps.get-extensions.outputs.extensions }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | |
| with: | |
| persist-credentials: false | |
| - name: Fetch extensions | |
| id: get-extensions | |
| run: | | |
| EXTENSIONS=() | |
| all_extensions=$(find . -type f -name metadata.hcl -exec dirname {} \; | sed 's|^\./||') | |
| for e in ${all_extensions}; do | |
| AUTO_UPDATE_OS_LIBS=$(sed -n 's/.*auto_update_os_libs *= *//p' "$e/metadata.hcl") | |
| if [[ $AUTO_UPDATE_OS_LIBS == "true" ]]; then | |
| EXTENSIONS+=("$e") | |
| fi | |
| done | |
| EXTENSIONS_JSON=$(printf "%s\n" "${EXTENSIONS[@]}" | jq -R -s -c 'split("\n")[:-1]') | |
| echo "extensions=$EXTENSIONS_JSON" >> $GITHUB_OUTPUT | |
| update-extension-os-libs: | |
| name: Update OS libs for ${{ matrix.extension }} | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - fetch-extensions | |
| strategy: | |
| matrix: | |
| extension: ${{ fromJson(needs.fetch-extensions.outputs.extensions) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | |
| - name: Log in to the GitHub Container registry | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update OS libs for ${{ matrix.extension }} | |
| env: | |
| EXTENSION_NAME: ${{ matrix.extension }} | |
| run: | | |
| make update-os-libs-$EXTENSION_NAME | |
| - name: Diff | |
| run: | | |
| git status | |
| git diff | |
| - name: Create a PR if versions have been updated on main | |
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7 | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| token: ${{ secrets.REPO_GHA_PAT }} | |
| title: "chore: update ${{ matrix.extension }} OS libraries" | |
| body: "Updating the OS libraries of ${{ matrix.extension }}" | |
| branch: "${{ matrix.extension }}-os-libraries" | |
| author: "extension-os-libs-updater <[email protected]>" | |
| add-paths: | | |
| ${{ matrix.extension }}/** | |
| commit-message: "chore: update ${{ matrix.extension }} OS libraries" | |
| signoff: true |