diff --git a/.github/workflows/_internal-get-composer-version.yaml b/.github/workflows/_internal-get-composer-version.yaml new file mode 100644 index 0000000..50ea83d --- /dev/null +++ b/.github/workflows/_internal-get-composer-version.yaml @@ -0,0 +1,39 @@ +name: Get Composer Version + +on: + push: + branches: + - main + - testing + paths: + - ".github/workflows/_internal-get-composer-version.yaml" + - "get-composer-version/**" + - "!(**/*.md)" + pull_request: + branches: + - main + paths: + - ".github/workflows/_internal-get-composer-version.yaml" + - "get-composer-version/**" + - "!(**/*.md)" + +jobs: + get-composer-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set PHP Version + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + tools: composer:v2.4.2 + + - uses: ./get-composer-version + id: composer-version + + + - name: Fail if versions do not match + if: steps.composer-version.outputs.version != '2.4.2' + shell: bash + run: echo "${{ steps.composer-version.outputs.version }}" && exit 1 + \ No newline at end of file diff --git a/get-composer-version/README.md b/get-composer-version/README.md new file mode 100644 index 0000000..db76645 --- /dev/null +++ b/get-composer-version/README.md @@ -0,0 +1,32 @@ +# "Get Composer Version" Action + +A Github Action that computes an installed Composer version. + +## Inputs + +See the [action.yml](./action.yml) + +## Usage + +```yml +name: Get Composer Version + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + version: + runs-on: ubuntu-latest + name: A job to compute an installed Composer version. + steps: + - uses: actions/checkout@v3 + - uses: mage-os/github-actions/get-composer-version@main + id: get-composer-version + - run: echo version ${{ steps.get-composer-version.outputs.version }} + shell: bash +``` diff --git a/get-composer-version/action.yml b/get-composer-version/action.yml new file mode 100644 index 0000000..7a74656 --- /dev/null +++ b/get-composer-version/action.yml @@ -0,0 +1,20 @@ +name: "Get Composer Version" +author: "Graycore" +description: " A Github Action that determines the currently installed version of Composer" + +outputs: + version: # id of output + description: 'The determined version of Composer' + value: ${{ steps.get-composer-version.outputs.version }} + +runs: + using: "composite" + steps: + - run: echo "version=$(composer --version | awk '{print $3}')" >> $GITHUB_OUTPUT + shell: bash + name: Compute Installed Composer version + id: get-composer-version + +branding: + icon: "code" + color: "green"