-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: update actions #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: update actions #226
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
44dd1fd
fix: update actions versions in workflows
Morgy93 d091dfe
fix: add concurrency settings to workflows
Morgy93 953341c
feat: add setup-magento action for CI workflows
Morgy93 1946ffb
fix: update workflows to validate pushes to main
Morgy93 9e76c37
feat: add composer-auth support for Mage-OS mirror
Morgy93 18f674b
fix: clarify composer-auth input description
Morgy93 8f92367
fix: update action versions and fix magento version format
Morgy93 7126ca2
fix: improve magento version handling in setup action
Morgy93 42c9de1
fix: extract metadata decoding to a separate method
Morgy93 ba3fea7
fix: update phpstan dependencies to pinned versions
Morgy93 050bf7d
fix: validate magento-source input for setup action
Morgy93 829ba05
fix: specify types in process run callback
Morgy93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| name: Set up Magento | ||
| description: >- | ||
| Provisions a Magento install for CI: sets up PHP + Composer, restores the | ||
| Composer download cache, fetches Magento (git clone or the Mage-OS mirror) and | ||
| runs `bin/magento setup:install`. The calling job must provide the MySQL/MariaDB | ||
| and OpenSearch service containers (reachable at 127.0.0.1:3306 / localhost:9200). | ||
| Leaves a ready install in ./magento2 next to the checked-out module. | ||
|
|
||
| inputs: | ||
| php-version: | ||
| description: PHP version passed to shivammathur/setup-php. | ||
| required: true | ||
| magento-version: | ||
| description: >- | ||
| Magento version. With magento-source=git it is the branch/tag to clone. | ||
| With magento-source=mage-os it pins `composer create-project` to that | ||
| release (falling back to the latest stable only if the mirror lacks that | ||
| exact version). Also namespaces the Composer cache. | ||
| required: true | ||
| magento-source: | ||
| description: >- | ||
| How to fetch Magento: "git" (github.com/magento/magento2) or "mage-os" | ||
| (composer create-project via the Mage-OS mirror). | ||
| required: false | ||
| default: git | ||
| php-extensions: | ||
| description: PHP extensions to install. | ||
| required: false | ||
| default: mbstring, intl, gd, xml, soap, zip, bcmath, pdo_mysql, curl, sockets | ||
| composer-auth: | ||
| description: >- | ||
| COMPOSER_AUTH JSON (Magento Marketplace keys) for authenticated Composer | ||
| downloads. Pass the calling workflow's secrets.COMPOSER_AUTH secret. | ||
| required: false | ||
| default: "" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| # Fail fast on a bad magento-source: otherwise both download steps' `if` | ||
| # conditions are false, no magento2/ is created, and the failure only | ||
| # surfaces later as a confusing "working-directory magento2 not found". | ||
| - name: Validate inputs | ||
| shell: bash | ||
| env: | ||
| MAGENTO_SOURCE: ${{ inputs.magento-source }} | ||
| run: | | ||
| case "$MAGENTO_SOURCE" in | ||
| git | mage-os) ;; | ||
| *) | ||
| echo "::error::Invalid magento-source '${MAGENTO_SOURCE}' (expected 'git' or 'mage-os')" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 | ||
| with: | ||
| php-version: ${{ inputs.php-version }} | ||
| extensions: ${{ inputs.php-extensions }} | ||
| tools: composer:v2 | ||
|
|
||
| # Caches ~/.composer/cache/files — Composer's content-addressed download | ||
| # cache, not a resolved dependency set. If the mage-os fallback installs a | ||
| # different release than magento-version implies, a mismatched key only | ||
| # causes cache misses (re-downloads), never an incorrect install: Composer | ||
| # always installs exactly what composer.json resolves to. | ||
| - name: Cache Composer packages | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | ||
| with: | ||
| path: ~/.composer/cache/files | ||
| key: ${{ runner.os }}-composer-${{ inputs.magento-version }}-${{ hashFiles('**/composer.json') }} | ||
| restore-keys: ${{ runner.os }}-composer-${{ inputs.magento-version }} | ||
|
|
||
| - name: Download Magento (git clone) | ||
| if: ${{ inputs.magento-source == 'git' }} | ||
| shell: bash | ||
| run: | | ||
| # Assign to a shell variable and quote it so an unexpected value can't | ||
| # word-split or glob into extra git arguments. | ||
| version="${{ inputs.magento-version }}" | ||
| git clone --depth=1 --branch="$version" \ | ||
| https://github.com/magento/magento2.git magento2 | ||
|
|
||
|
Morgy93 marked this conversation as resolved.
|
||
| - name: Download Magento (Mage-OS mirror) | ||
| if: ${{ inputs.magento-source == 'mage-os' }} | ||
| shell: bash | ||
| env: | ||
| COMPOSER_AUTH: ${{ inputs.composer-auth }} | ||
| run: | | ||
| # Pin create-project to the requested version so runs are reproducible, | ||
| # falling back to the latest stable only if the mirror lacks that exact | ||
| # release. --no-install: scaffold only here; the "Install Magento" step | ||
| # below installs dependencies exactly once (with COMPOSER_AUTH), instead | ||
| # of create-project installing them unauthenticated and the install step | ||
| # installing them a second time. | ||
| mirror=https://mirror.mage-os.org/ | ||
| version="${{ inputs.magento-version }}" | ||
| if ! composer create-project --no-install --repository-url="$mirror" \ | ||
| magento/project-community-edition magento2 "$version"; then | ||
| echo "::warning::Mage-OS mirror has no project-community-edition ${version}; using latest stable" | ||
| rm -rf magento2 | ||
| composer create-project --no-install --repository-url="$mirror" \ | ||
| magento/project-community-edition magento2 | ||
| fi | ||
|
Morgy93 marked this conversation as resolved.
|
||
|
|
||
| - name: Install Magento | ||
| working-directory: magento2 | ||
| shell: bash | ||
| env: | ||
| COMPOSER_AUTH: ${{ inputs.composer-auth }} | ||
| run: | | ||
| composer config minimum-stability stable | ||
| composer config prefer-stable true | ||
| composer install --no-interaction --no-progress | ||
| bin/magento setup:install \ | ||
| --base-url=http://localhost \ | ||
| --db-host=127.0.0.1 \ | ||
| --db-name=magento \ | ||
| --db-user=root \ | ||
| --db-password=magento \ | ||
| --admin-firstname=Admin \ | ||
| --admin-lastname=User \ | ||
| --admin-email=admin@example.com \ | ||
| --admin-user=admin \ | ||
| --admin-password=admin12345 \ | ||
| --language=en_US \ | ||
| --currency=USD \ | ||
| --timezone=Europe/Berlin \ | ||
| --use-rewrites=1 \ | ||
| --backend-frontname=admin \ | ||
| --search-engine=opensearch \ | ||
| --opensearch-host=localhost \ | ||
| --opensearch-port=9200 \ | ||
| --opensearch-index-prefix=magento \ | ||
| --cleanup-database | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.