diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml deleted file mode 100644 index e431762..0000000 --- a/.github/workflows/update_version.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Update version - -on: - workflow_dispatch: - schedule: - - cron: '30 */4 * * *' - -jobs: - update-version: - name: Automatically get latest PHPArkitect version and commit - - runs-on: ubuntu-latest - - steps: - - name: "Checkout code" - uses: actions/checkout@v3 - with: - ref: main - fetch-depth: '0' - - - name: "Update Dockerfile and action.yml" - id: fetch_version - run: | - latest=$(curl -s https://repo.packagist.org/p2/phparkitect/phparkitect.json | jq -r '.packages[][0] | .version') - - echo "Latest PHPArkitect version is $latest" - echo "latest=$latest" >> "$GITHUB_OUTPUT" - - sed -i -re "s/ENV VERSION=.*/ENV VERSION=$latest/" Dockerfile - cat Dockerfile - - sed -i -re "s/arkitect-github-actions:[0-9.]+/arkitect-github-actions:$latest/" action.yml - cat action.yml - - - name: "Commit changes" - uses: stefanzweifel/git-auto-commit-action@v4 - id: commit - with: - commit_author: "Alessandro Minoccheri " - commit_message: "Enhancement: Upgrade to PHPArkitect ${{ steps.fetch_version.outputs.latest }}" - commit_user_email: "alessandro.minoccheri@gmail.com" - commit_user_name: "Alessandro Minoccheri" - - - name: "Tag version ${{ steps.fetch_version.outputs.latest }}" - uses: "anothrNick/github-tag-action@1.30.0" - if: steps.commit.outputs.changes_detected == 'true' - id: tag - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CUSTOM_TAG: ${{ steps.fetch_version.outputs.latest }} - RELEASE_BRANCHES: main - - - name: "Create release ${{ steps.fetch_version.outputs.latest }}" - uses: actions/create-release@v1 - if: steps.commit.outputs.changes_detected == 'true' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.tag.outputs.new_tag }} - release_name: ${{ steps.tag.outputs.new_tag }} - commitish: main - body: "Upgrade PHPArkitect to ${{ steps.tag.outputs.new_tag }}" - - publish_docker_images: - needs: [update-version] - runs-on: ubuntu-22.04 - - if: github.ref == 'refs/heads/main' || github.event_name == 'release' - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Docker meta - id: meta - uses: crazy-max/ghaction-docker-meta@v2 - with: - images: phparkitect/arkitect-github-actions - tags: | - type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }} - type=ref,event=tag - flavor: | - latest=false - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - diff --git a/Dockerfile b/Dockerfile index e1db017..cc0e730 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,10 @@ ENV COMPOSER_HOME=/composer RUN echo "memory_limit=-1" > $PHP_INI_DIR/conf.d/memory-limit.ini -ENV VERSION=0.7.0 +# Default version - can be overridden via action input +ENV DEFAULT_VERSION=* -RUN composer global require phparkitect/phparkitect $VERSION \ +RUN composer global require phparkitect/phparkitect ${DEFAULT_VERSION} \ && composer global require phpunit/phpunit \ && composer global show "*phparkitect*" diff --git a/README.md b/README.md index de20795..428c67d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,30 @@ This repository is created for run PHPArkitect into Github Actions +## ⚠️ Migration from v0.x + +If you're currently using the old Docker image format: +```yaml +uses: docker://phparkitect/arkitect-github-actions:0.7.0 +``` + +Please update to the new format for better flexibility and automatic updates: +```yaml +uses: phparkitect/arkitect-github-actions@main +with: + phparkitect-version: '0.7.0' # optional, defaults to latest +``` + +**Benefits of migrating:** +- Choose any PHPArkitect version without waiting for action releases +- Get automatic updates when using default version +- Support for version constraints (e.g., `^0.7`, `*`) + ## Usage You can use it as a Github Action like this: ```yaml -# .github/workflows/test.yml +# .github/workflows/test.yml on: push: @@ -27,24 +46,60 @@ jobs: uses: actions/checkout@v2 - name: PHPArkitect - uses: docker://phparkitect/arkitect-github-actions + uses: phparkitect/arkitect-github-actions@main with: args: check ``` -_to use a specific php version:_ -```diff - uses: docker://phparkitect/arkitect-github-actions -+ env: -+ PHP_VERSION: 8.0 +### Configuration Options + +#### Specify PHPArkitect version +You can specify which version of PHPArkitect to use: + +```yaml + - name: PHPArkitect + uses: phparkitect/arkitect-github-actions@main with: + phparkitect-version: '0.7.0' # specific version args: check ``` -## Building and pushing the docker image +Or use version constraints: +```yaml + phparkitect-version: '^0.7' # latest 0.7.x + phparkitect-version: '*' # latest stable (default) +``` + +#### Specify PHP version +To use a specific PHP version for platform requirements check: +```yaml + - name: PHPArkitect + uses: phparkitect/arkitect-github-actions@main + env: + PHP_VERSION: 8.0 + with: + args: check ``` -docker login + +## Development + +### How it works +The GitHub Action now builds the Docker image locally for each workflow run. This allows users to specify which version of PHPArkitect they want to use without requiring a new release of this action for every PHPArkitect update. + +### Building the docker image locally +If you want to build and test the image locally: + +```bash docker build -t phparkitect/arkitect-github-actions:latest . -docker push phparkitect/arkitect-github-actions:latest +docker run --rm phparkitect/arkitect-github-actions:latest --version ``` + +### Release Strategy +Releases of this GitHub Action are only needed when: +- The action configuration changes (action.yml) +- The entrypoint script changes (entrypoint.sh) +- The Dockerfile structure changes +- New features are added to the action itself + +**No release is needed** for PHPArkitect version updates, as users can specify their desired version via the `phparkitect-version` input. diff --git a/action.yml b/action.yml index 802eab5..9a190e3 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,12 @@ description: "Use Arkitect via GithubAction." name: "phparkitect-arkitect" +inputs: + phparkitect-version: + description: "PHPArkitect version to use (e.g., 0.7.0, ^0.7, *). Defaults to latest stable version." + required: false + default: "*" + runs: using: "docker" - image: "docker://phparkitect/arkitect-github-actions:0.7.0" + image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh index 70a2a00..c00d4ed 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,13 @@ set -e +# Handle custom PHPArkitect version if specified +if [ -n "$INPUT_PHPARKITECT_VERSION" ]; then + echo "::group::Installing PHPArkitect version $INPUT_PHPARKITECT_VERSION" + composer global require phparkitect/phparkitect "$INPUT_PHPARKITECT_VERSION" + echo "::endgroup::" +fi + /composer/vendor/bin/phparkitect --version IGNORE_PLATFORM_REQS=""