Skip to content

Commit

Permalink
Update action
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgrul committed Feb 25, 2024
1 parent d801c74 commit c7ea513
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Composer Satis Repository Generator

| Version | Latest Commit | Nightly Build |
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `main` | [![Latest Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml/badge.svg?branch=main)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml) | [![Nightly Main Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-main-test-action.yml/badge.svg)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-main-test-action.yml) |
| `v1` | [![Latest Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml/badge.svg?branch=releases%2Fv1)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml) | [![Nightly v1 Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-v1-test-action.yml/badge.svg)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-v1-test-action.yml) |
| Version | Latest Commit | Nightly Build |
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `main` | [![Latest Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml/badge.svg?branch=main)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml) | [![Nightly Main Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-main-test-action.yml/badge.svg)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-main-test-action.yml) |
| `v1` | [![Latest Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml/badge.svg?branch=releases%2Fv1)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/event-test-action.yml) | [![Nightly v1 Test](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-v1-test-action.yml/badge.svg)](https://github.com/mattgrul/satis-to-artifact-action/actions/workflows/nightly-v1-test-action.yml) |

Build a Composer Satis repository and output the final build to a GitHub artifact.

### Private Repositories

For private GitHub repositories hosted on the same user account or organization the default `github` context is used
within the action like
so `${{ github.token }}`. This sets the composer `github-oauth` token within the runner and allows private repositories
to be added to the Satis config file.
For private GitHub repositories you can pass a token through using the `composer-token` input. This sets the
composer `github-oauth` token within the runner and allows private repositories to be added to the Satis config file.

## Usage

Expand Down Expand Up @@ -45,6 +43,7 @@ jobs:
name: 'Run Generate Satis Repository Action'
uses: masheto-org/satis-to-artifact-action@v1
with:
composer-token: ${{ secrets.SECRET_NAME }}
composer-version: 2.2 # Composer version 2.2
php-version: 8.1 # PHP version 8.1
satis-version: fafc1c2eca6394235f12f8a3ee4da7fc7c9fc874 # Satis from the commit SHA fafc1c2eca6394235f12f8a3ee4da7fc7c9fc874
Expand All @@ -62,8 +61,9 @@ There are 7 input values that can be configured for the action which are as foll
| Name | Required | Default | Description |
|---------------------------------------------|----------|--------------------------|-----------------------------------------------|
| [composer-version](#php--composer-versions) | No | 2.6 | The Composer version to use |
| [php-version](#php--composer-versions) | No | 8.3 | The PHP version to use |
| [composer-token](#composer-token) | No | `${{github.token}}` | The GitHub token to use |
| [composer-version](#php--composer-versions) | No | 2.6 | The Composer version to use |
| [satis-version](#satis-version) | No | main | The version of Satis to use |
| [satis-config](#satis-config) | No | `${{github.workspace}}` | The path to the Satis config file |
| [cache-composer](#cache-composer) | No | true | Whether or not to cache the composer files |
Expand All @@ -81,6 +81,16 @@ The latest stable version of composer is set up by default. You can set up the r
the major version v1 or v2, or the version in major.minor or semver format. Additionally, for composer snapshot a
preview can also be specified to set up the respective releases.

### Composer Token

If you need to access private repositories you can pass a token through using the `composer-token` input. The token
should be created as a secret and passed through securely, for example `composer-token: ${{ secrets.SECRET_NAME }}`. For
more information on creating a secret see
the [GitHub documentation](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions).

By default, the action uses the token `${{ github.token if no composer-token is provided which will allow access to the
repository the action is running on.

### Cache Composer

Caching of the Composer cache directory is enabled by default, which speeds up the action by reusing the Composer files
Expand Down
14 changes: 11 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
description: 'The version of PHP to use.'
required: false
default: '8.3'
composer-token:
description: 'Token for Composer authentication.'
required: false
composer-version:
description: 'The version of Composer to use.'
required: false
Expand Down Expand Up @@ -53,7 +56,12 @@ runs:

- id: configure-composer
name: 'Configure Composer GitHub Token'
run: composer config --global --auth github-oauth.github.com ${{ github.token }}
run: |
if [ -n "${{ inputs.composer-token }}" ]; then
composer config --global --auth github-oauth.github.com ${{ inputs.composer-token }}
else
composer config --global --auth github-oauth.github.com ${{ github.token }}
fi
shell: bash

- id: download-satis
Expand Down Expand Up @@ -85,7 +93,7 @@ runs:
name: 'Run Composer Install'
run: |
cd ${{ env.SATIS_PATH }}
composer install
composer install --no-progress --prefer-dist --optimize-autoloader
shell: bash

- id: run-satis
Expand Down Expand Up @@ -119,4 +127,4 @@ runs:
if: ${{ success() }}
name: 'Set Artifact Name As Output'
run: echo "satis-artifact=${{ inputs.artifact-name }}-${{ github.run_id }}" >> $GITHUB_OUTPUT
shell: bash
shell: bash

0 comments on commit c7ea513

Please sign in to comment.