Cache PHP #63
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: 'Cache PHP' | |
| on: | |
| schedule: | |
| - cron: '15 1 */15 * *' | |
| workflow_dispatch: | |
| inputs: | |
| php-versions: | |
| description: 'PHP version to cache' | |
| default: '8.1 8.2 8.3 8.4' | |
| required: true | |
| jobs: | |
| get-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| php_matrix: ${{ steps.set-matrix.outputs.php_matrix }} | |
| steps: | |
| - name: Get matrix | |
| id: set-matrix | |
| run: | | |
| IFS=' ' read -r -a PHP_VERSIONS <<<"${{ inputs.php-versions || '8.1 8.2 8.3 8.4' }}" | |
| php_array=() | |
| for php in "${PHP_VERSIONS[@]}"; do | |
| php_array+=("{\"php\": \"$php\"}") | |
| done | |
| echo "php_matrix={\"include\":[$(echo "${php_array[@]}" | sed -e 's|} {|}, {|g')]}" | |
| echo "php_matrix={\"include\":[$(echo "${php_array[@]}" | sed -e 's|} {|}, {|g')]}" >> "$GITHUB_OUTPUT" | |
| cache: | |
| needs: get-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: ${{fromJson(needs.get-matrix.outputs.php_matrix)}} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create builds directory | |
| run: mkdir builds | |
| - name: Fetch files | |
| run: bash scripts/fetch.sh ${{ matrix.php }} builds | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.x | |
| - name: Install cloudsmith-cli | |
| run: pip install --upgrade cloudsmith-cli | |
| - name: Release | |
| run: bash scripts/release.sh | |
| env: | |
| CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} | |
| GITHUB_MESSAGE: ${{ github.event.head_commit.message }} | |
| GITHUB_RELEASES: php${{ matrix.php }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |