Skip to content

Commit fd858c3

Browse files
authored
feat(get-magento-version): add get-magento-version action (graycoreio#72)
1 parent 158bd0b commit fd858c3

File tree

4 files changed

+109
-2
lines changed

4 files changed

+109
-2
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Get Magento Version
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/_internal-get-magento-version.yaml"
9+
- "get-magento-version/**"
10+
- "!(**/*.md)"
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- ".github/workflows/_internal-get-magento-version.yaml"
16+
- "get-magento-version/**"
17+
- "!(**/*.md)"
18+
19+
jobs:
20+
get-magento-version:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Set PHP Version
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: 8.1
28+
tools: composer:v2.4.2
29+
30+
- run: composer create-project --repository-url="https://mirror.mage-os.org" "magento/project-community-edition:2.4.5-p1" ../magento2 --no-install
31+
shell: bash
32+
name: Create Magento ${{ matrix.magento }} Project
33+
34+
- uses: ./get-magento-version
35+
id: magento-version
36+
with:
37+
working-directory: ../magento2
38+
39+
- name: Fail if key does not match
40+
if: steps.magento-version.outputs.version != '"2.4.5-p1"'
41+
shell: bash
42+
run: echo "${{ steps.magento-version.outputs.version }}" && exit 1
43+

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ Opinionated Github Actions and Workflows to make building, testing, and maintain
2626
| Action Name | Description |
2727
| ------------------------------------------------ | ------------------------------------------------------------------ |
2828
| [Unit Test](./unit-test/README.md) | A Github Action that runs the Unit Tests a Magento Package |
29-
| [Installation Test](installation-test/README.md) | A Github Action that tests the installability of a Magento Package |
30-
| [Supported Version](supported-version/README.md) | A Github Action that computes the currently supported Github Actions Matrix for Magento 2 |
29+
| [Get Magento Version](./get-magento-version/README.md) | A Github Action that computes the installed Magento version. |
30+
| [Installation Test](./installation-test/README.md) | A Github Action that tests the installability of a Magento Package |
31+
| [Supported Version](./supported-version/README.md) | A Github Action that computes the currently supported Github Actions Matrix for Magento 2 |

get-magento-version/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# "Get Magento Version" Action
2+
3+
A Github Action that computes an installed Magento version.
4+
5+
## Inputs
6+
7+
See the [action.yml](./action.yml)
8+
9+
## Usage
10+
11+
```yml
12+
name: Get Magento Version
13+
14+
on:
15+
push:
16+
branches:
17+
- main
18+
pull_request:
19+
branches:
20+
- main
21+
22+
jobs:
23+
version:
24+
runs-on: ubuntu-latest
25+
name: A job to compute an installed Magento version.
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: graycoreio/github-actions-magento2/get-magento-version@main
29+
id: get-magento-version
30+
- run: echo version ${{ steps.get-magento-version.outputs.version }}
31+
shell: bash
32+
```

get-magento-version/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Get Magento Version"
2+
author: "Graycore"
3+
description: " A Github Action that determines the currently installed version of Magento"
4+
5+
inputs:
6+
working-directory:
7+
default: $GITHUB_WORKSPACE
8+
description: "The current working directory of the action"
9+
required: false
10+
11+
outputs:
12+
version: # id of output
13+
description: 'The determined version of Magento'
14+
value: ${{ steps.get-magento-version.outputs.version }}
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- run: |
20+
echo "::set-output name=version::$(cat composer.json | jq '.require
21+
| with_entries( select(.key == "magento/product-community-edition" or .key == "magento/product-enterprise-edition") )
22+
| to_entries
23+
| .[0].value')"
24+
shell: bash
25+
working-directory: ${{ inputs.working-directory }}
26+
name: Compute Installed Magento version
27+
id: get-magento-version
28+
29+
branding:
30+
icon: "code"
31+
color: "green"

0 commit comments

Comments
 (0)