|
| 1 | +name: Ports |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +env: |
| 7 | + FORCE_COLOR: 3 |
| 8 | + |
| 9 | +jobs: |
| 10 | + update-port: |
| 11 | + runs-on: ubuntu-24.04 |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + id-token: write |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Generate a bot token with BOT_APP_ID |
| 19 | + id: bot_token |
| 20 | + if: vars.BOT_APP_ID && env.BOT_PRIVATE_KEY != null |
| 21 | + uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1 |
| 22 | + env: |
| 23 | + BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }} |
| 24 | + with: |
| 25 | + app-id: ${{ vars.BOT_APP_ID }} |
| 26 | + private-key: ${{ secrets.BOT_PRIVATE_KEY }} |
| 27 | + |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 30 | + with: |
| 31 | + token: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }} |
| 32 | + ref: ${{ github.head_ref }} |
| 33 | + fetch-depth: 2 |
| 34 | + |
| 35 | + - name: Format vcpkg.json |
| 36 | + run: | |
| 37 | + vcpkg format-manifest --all $(find cmake/vcpkg/ports/ -name "vcpkg.json") |
| 38 | +
|
| 39 | + - name: Commit format vcpkg.json |
| 40 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 41 | + if: success() |
| 42 | + with: |
| 43 | + commit_message: 'ci: format vcpkg configuration' |
| 44 | + file_pattern: vcpkg.json |
| 45 | + |
| 46 | + - name: Exit 1 if vcpkg configuration changes have been detected |
| 47 | + if: steps.auto-commit-action.outputs.changes_detected == 'true' |
| 48 | + run: | |
| 49 | + exit 1 |
| 50 | +
|
| 51 | + - name: Verify all modules and update hash |
| 52 | + run: | |
| 53 | + set -x |
| 54 | + for dir in cmake/vcpkg/ports/* ; do |
| 55 | + echo "Test to install $dir" |
| 56 | + if [[ ! -d $dir ]]; then continue; fi; |
| 57 | + vcpkg remove ${dir##cmake/vcpkg/ports/} --recurse --overlay-ports=cmake/vcpkg/ports --classic || true |
| 58 | + status=0 |
| 59 | + install_output=$(vcpkg install ${dir##cmake/vcpkg/ports/} --overlay-ports=cmake/vcpkg/ports --classic) || status=$? |
| 60 | + if [[ ! $status -eq 0 ]]; then |
| 61 | + echo " Update hash on $dir/portfile.cmake" |
| 62 | + expected=$(echo "$install_output" | grep -oP "(?<=Expected hash: ).{128}") |
| 63 | + actual=$(echo "$install_output" | grep -oP "(?<=Actual hash: ).{128}") |
| 64 | + sed -i "s@${expected}@${actual}@g" "$dir/portfile.cmake" |
| 65 | + echo " Expected hash: ${expected}" |
| 66 | + echo " Actual hash: ${actual}" |
| 67 | + fi |
| 68 | + done |
| 69 | +
|
| 70 | + - name: Detect hash changes against local |
| 71 | + id: filter-hash |
| 72 | + uses: dorny/paths-filter@v3 |
| 73 | + with: |
| 74 | + list-files: shell |
| 75 | + base: HEAD |
| 76 | + filters: | |
| 77 | + ports: |
| 78 | + - cmake/vcpkg/ports/** |
| 79 | +
|
| 80 | + - name: Commit port hash |
| 81 | + if: steps.filter-hash.outputs.ports == 'true' |
| 82 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 83 | + with: |
| 84 | + file_pattern: cmake/vcpkg/ports/* |
| 85 | + commit_message: 'ci: update port hash' |
| 86 | + skip_fetch: true |
0 commit comments