action.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: "Install Composer deps"
  2. inputs:
  3. flags:
  4. description: 'Composer flags'
  5. required: false
  6. runs:
  7. using: "composite"
  8. steps:
  9. # Warning!
  10. # Use $GITHUB_ENV instead of $GITHUB_OUTPUT.
  11. #
  12. # The actions/cache is, on calling it in this composite action, reading the cache,
  13. # and then also register a shutdown function for the whole workflow, to write the cache afterwards.
  14. #
  15. # That registered shutdown function does _NOT_ have access to inputs.* nor steps.*.outputs for
  16. # `path` parameter, which is evaluated on both stages (read and write), yet `key` parameters
  17. # are evaluated on start only and are not affected by this issue.
  18. #
  19. # Unfortunately, when the issue is faced, it does not break the build, simply raises a warning
  20. # and completing the build successfully, yet without storing the cache:
  21. # > Warning: Input required and not supplied: path
  22. #
  23. # Refs:
  24. # - https://github.com/actions/cache/issues/638#issuecomment-1793564996
  25. # - https://github.com/actions/cache/issues/803#issuecomment-1793565071
  26. # - https://github.com/actions/runner/issues/2009#issuecomment-1793565031
  27. - name: Get Composer cache params
  28. shell: bash
  29. run: |
  30. echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
  31. echo "COMPOSER_CACHE_PHP=$(php -r 'echo PHP_VERSION;')" >> $GITHUB_ENV
  32. echo "PHP_VERSION_ID=$(php -r 'echo PHP_VERSION_ID;')" >> $GITHUB_ENV
  33. - name: Cache Composer dependencies
  34. uses: actions/cache@v4
  35. with:
  36. path: ${{ env.COMPOSER_CACHE_DIR }}
  37. key: Composer-${{ runner.os }}-${{ env.COMPOSER_CACHE_PHP }}-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
  38. restore-keys: |
  39. Composer-${{ runner.os }}-${{ env.COMPOSER_CACHE_PHP }}-${{ hashFiles('**/composer.json') }}-
  40. Composer-${{ runner.os }}-${{ env.COMPOSER_CACHE_PHP }}-
  41. Composer-${{ runner.os }}-
  42. - name: Install dependencies
  43. uses: nick-invision/retry@v3
  44. with:
  45. timeout_minutes: 5
  46. max_attempts: 5
  47. retry_wait_seconds: 30
  48. # `--no-scripts` to avoid side-effects (e.g. installing dev-tools for all jobs on CI level),
  49. # all executed scripts should be explicit and run only when needed.
  50. command: composer update --optimize-autoloader --no-interaction --no-progress --no-scripts ${{ inputs.flags }}
  51. - name: Show versions of packages
  52. shell: bash
  53. run: composer info -D