Skip to content
This repository was archived by the owner on Feb 10, 2026. It is now read-only.

Commit 559eeb2

Browse files
committed
Implement high-priority improvements to GitHub Action
## Dockerfile improvements: - Upgrade to latest Composer version (from 2.5.5) - Remove unused PHPUnit dependency - Replace deprecated labels with modern OCI labels - Add git and unzip dependencies - Use COPY instead of ADD for entrypoint - Add explicit chmod +x for entrypoint - Improve comments and structure ## entrypoint.sh improvements: - Replace $* with "$@" for proper argument handling - Add --no-interaction flag to composer install - Improve output formatting with GitHub Actions groups - Add clearer log messages - Better variable naming and structure - Add shellcheck disable comments where needed ## update_version.yml improvements: - Replace deprecated actions/create-release@v1 with gh CLI - Upgrade docker/metadata-action from v2 to v5 - Upgrade docker/login-action from v1 to v3 - Upgrade docker/build-push-action from v2 to v5 - Add docker/setup-buildx-action@v3 for improved builds - Add Docker layer caching with GitHub Actions cache - Update actions/checkout from v3 to v4 ## README.md improvements: - Complete rewrite with better structure - Update examples to use actions/checkout@v4 - Add comprehensive configuration table - Document all environment variables - Add advanced usage examples - Add matrix build example - Improve formatting and readability - Add contributing and license sections All changes maintain backward compatibility while modernizing the action.
1 parent 7f2b3e6 commit 559eeb2

File tree

4 files changed

+189
-66
lines changed

4 files changed

+189
-66
lines changed

.github/workflows/update_version.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,45 +51,52 @@ jobs:
5151
RELEASE_BRANCHES: main
5252

5353
- name: "Create release ${{ steps.fetch_version.outputs.latest }}"
54-
uses: actions/create-release@v1
5554
if: steps.commit.outputs.changes_detected == 'true'
5655
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
with:
59-
tag_name: ${{ steps.tag.outputs.new_tag }}
60-
release_name: ${{ steps.tag.outputs.new_tag }}
61-
commitish: main
62-
body: "Upgrade PHPArkitect to ${{ steps.tag.outputs.new_tag }}"
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: |
58+
gh release create "${{ steps.tag.outputs.new_tag }}" \
59+
--title "${{ steps.tag.outputs.new_tag }}" \
60+
--notes "Upgrade PHPArkitect to ${{ steps.tag.outputs.new_tag }}" \
61+
--target main
6362
6463
publish_docker_images:
6564
needs: [update-version]
6665
runs-on: ubuntu-22.04
67-
66+
6867
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
6968
steps:
7069
- name: Checkout
71-
uses: actions/checkout@v3
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
7275
- name: Docker meta
7376
id: meta
74-
uses: crazy-max/ghaction-docker-meta@v2
77+
uses: docker/metadata-action@v5
7578
with:
7679
images: phparkitect/arkitect-github-actions
7780
tags: |
7881
type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }}
7982
type=ref,event=tag
8083
flavor: |
8184
latest=false
85+
8286
- name: Login to DockerHub
8387
if: github.event_name != 'pull_request'
84-
uses: docker/login-action@v1
88+
uses: docker/login-action@v3
8589
with:
8690
username: ${{ secrets.DOCKERHUB_USERNAME }}
8791
password: ${{ secrets.DOCKERHUB_TOKEN }}
92+
8893
- name: Build and push
89-
uses: docker/build-push-action@v2
94+
uses: docker/build-push-action@v5
9095
with:
9196
context: .
9297
push: ${{ github.event_name != 'pull_request' }}
9398
tags: ${{ steps.meta.outputs.tags }}
9499
labels: ${{ steps.meta.outputs.labels }}
100+
cache-from: type=gha
101+
cache-to: type=gha,mode=max
95102

Dockerfile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
FROM php:8.2-alpine
22

3-
LABEL "com.github.actions.name"="PHPArkitect-arkitect"
4-
LABEL "com.github.actions.description"="arkitect"
5-
LABEL "com.github.actions.icon"="check"
6-
LABEL "com.github.actions.color"="blue"
7-
8-
LABEL "repository"="http://github.com/phparkitect/arkitect-github-actions"
9-
LABEL "homepage"="http://github.com/actions"
10-
LABEL "maintainer"="Alessandro Minoccheri <alessandro.minoccheri@gmail.com>"
11-
12-
COPY --from=composer:2.5.5 /usr/bin/composer /usr/local/bin/composer
3+
# Modern OCI labels
4+
LABEL org.opencontainers.image.title="PHPArkitect GitHub Action"
5+
LABEL org.opencontainers.image.description="Enforce architectural rules in PHP projects using PHPArkitect"
6+
LABEL org.opencontainers.image.source="https://github.com/phparkitect/arkitect-github-actions"
7+
LABEL org.opencontainers.image.url="https://github.com/phparkitect/arkitect-github-actions"
8+
LABEL org.opencontainers.image.documentation="https://github.com/phparkitect/arkitect-github-actions/blob/main/README.md"
9+
LABEL org.opencontainers.image.vendor="PHPArkitect"
10+
LABEL org.opencontainers.image.licenses="MIT"
11+
LABEL maintainer="Alessandro Minoccheri <alessandro.minoccheri@gmail.com>"
12+
13+
# Install git (required for Composer) and other dependencies
14+
RUN apk add --no-cache git unzip
15+
16+
# Use latest Composer version
17+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
1318

1419
RUN mkdir /composer
1520
ENV COMPOSER_HOME=/composer
21+
ENV PATH="/composer/vendor/bin:${PATH}"
1622

23+
# Configure PHP
1724
RUN echo "memory_limit=-1" > $PHP_INI_DIR/conf.d/memory-limit.ini
1825

19-
ENV VERSION=0.7.0
26+
# PHPArkitect version
27+
ARG VERSION=0.7.0
28+
ENV VERSION=${VERSION}
29+
30+
# Install PHPArkitect globally
31+
RUN composer global require phparkitect/phparkitect:${VERSION} --no-interaction --prefer-dist \
32+
&& composer global show phparkitect/phparkitect
2033

21-
RUN composer global require phparkitect/phparkitect $VERSION \
22-
&& composer global require phpunit/phpunit \
23-
&& composer global show "*phparkitect*"
34+
COPY entrypoint.sh /entrypoint.sh
35+
RUN chmod +x /entrypoint.sh
2436

25-
ADD entrypoint.sh /entrypoint.sh
2637
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 119 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,147 @@
1-
# GithubAction for Arkitect
1+
# GitHub Action for PHPArkitect
22

3-
This repository is created for run PHPArkitect into Github Actions
3+
This GitHub Action allows you to run [PHPArkitect](https://github.com/phparkitect/phparkitect) in your CI/CD pipeline to enforce architectural rules in your PHP projects.
44

55
## Usage
6-
You can use it as a Github Action like this:
6+
7+
### Basic Usage
78

89
```yaml
9-
# .github/workflows/test.yml
10+
# .github/workflows/architecture.yml
11+
12+
name: Architecture Tests
1013

1114
on:
1215
push:
1316
branches:
14-
- master
17+
- main
1518
pull_request:
1619

17-
name: Test
18-
1920
jobs:
2021
phparkitect:
2122
name: PHPArkitect
22-
2323
runs-on: ubuntu-latest
2424

2525
steps:
26-
- name: "Checkout"
27-
uses: actions/checkout@v2
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Run PHPArkitect
30+
uses: phparkitect/arkitect-github-actions@main
31+
with:
32+
args: check
33+
```
2834
29-
- name: PHPArkitect
30-
uses: docker://phparkitect/arkitect-github-actions
31-
with:
32-
args: check
35+
### Advanced Configuration
36+
37+
#### Using a specific PHP version for analysis
38+
39+
```yaml
40+
- name: Run PHPArkitect
41+
uses: phparkitect/arkitect-github-actions@main
42+
env:
43+
PHP_VERSION: 8.0
44+
with:
45+
args: check
3346
```
3447
35-
_to use a specific php version:_
36-
```diff
37-
uses: docker://phparkitect/arkitect-github-actions
38-
+ env:
39-
+ PHP_VERSION: 8.0
40-
with:
41-
args: check
48+
#### Installing dev dependencies
49+
50+
```yaml
51+
- name: Run PHPArkitect
52+
uses: phparkitect/arkitect-github-actions@main
53+
env:
54+
REQUIRE_DEV: true
55+
with:
56+
args: check
4257
```
4358
44-
## Building and pushing the docker image
59+
#### Ignoring platform requirements
4560
61+
```yaml
62+
- name: Run PHPArkitect
63+
uses: phparkitect/arkitect-github-actions@main
64+
env:
65+
CHECK_PLATFORM_REQUIREMENTS: false
66+
with:
67+
args: check
4668
```
69+
70+
## Configuration Options
71+
72+
### Inputs
73+
74+
| Input | Description | Required | Default |
75+
|-------|-------------|----------|---------|
76+
| `args` | Arguments to pass to PHPArkitect (e.g., `check`, `list`) | No | `check` |
77+
78+
### Environment Variables
79+
80+
| Variable | Description | Default |
81+
|----------|-------------|---------|
82+
| `PHP_VERSION` | Target PHP version for analysis (e.g., `7.4`, `8.0`, `8.2`) | - |
83+
| `REQUIRE_DEV` | Install dev dependencies (`true` or `false`) | `false` |
84+
| `CHECK_PLATFORM_REQUIREMENTS` | Check platform requirements (`true` or `false`) | `true` |
85+
86+
## Example: Complete Workflow
87+
88+
```yaml
89+
name: Architecture Tests
90+
91+
on:
92+
push:
93+
branches:
94+
- main
95+
- develop
96+
pull_request:
97+
98+
jobs:
99+
phparkitect:
100+
name: PHPArkitect
101+
runs-on: ubuntu-latest
102+
103+
strategy:
104+
matrix:
105+
php-version: ['8.0', '8.1', '8.2']
106+
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
111+
- name: Run PHPArkitect for PHP ${{ matrix.php-version }}
112+
uses: phparkitect/arkitect-github-actions@main
113+
env:
114+
PHP_VERSION: ${{ matrix.php-version }}
115+
with:
116+
args: check
117+
```
118+
119+
## Development
120+
121+
### Building and pushing the Docker image
122+
123+
The Docker image is automatically built and published when a new PHPArkitect version is released.
124+
125+
For manual builds:
126+
127+
```bash
47128
docker login
48129
docker build -t phparkitect/arkitect-github-actions:latest .
49130
docker push phparkitect/arkitect-github-actions:latest
50131
```
132+
133+
### Testing locally
134+
135+
```bash
136+
# Run the action locally
137+
docker build -t phparkitect-action .
138+
docker run -v $(pwd):/github/workspace phparkitect-action check
139+
```
140+
141+
## Contributing
142+
143+
Contributions are welcome! Please feel free to submit a Pull Request.
144+
145+
## License
146+
147+
MIT

entrypoint.sh

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@
22

33
set -e
44

5-
/composer/vendor/bin/phparkitect --version
5+
echo "::group::PHPArkitect Version"
6+
phparkitect --version
7+
echo "::endgroup::"
68

7-
IGNORE_PLATFORM_REQS=""
8-
if [ "$CHECK_PLATFORM_REQUIREMENTS" = "false" ]; then
9-
IGNORE_PLATFORM_REQS="--ignore-platform-reqs"
10-
fi
9+
# Build composer install flags
10+
COMPOSER_FLAGS="--no-progress --no-interaction"
1111

12-
NO_DEV="--no-dev"
13-
if [ "$REQUIRE_DEV" = "true" ]; then
14-
NO_DEV=""
12+
if [ "${CHECK_PLATFORM_REQUIREMENTS}" = "false" ]; then
13+
COMPOSER_FLAGS="${COMPOSER_FLAGS} --ignore-platform-reqs"
1514
fi
1615

17-
TARGET_PHP_VERSION=""
18-
if [ -n "$PHP_VERSION" ]
19-
then
20-
TARGET_PHP_VERSION=" --target-php-version=$PHP_VERSION"
16+
if [ "${REQUIRE_DEV}" != "true" ]; then
17+
COMPOSER_FLAGS="${COMPOSER_FLAGS} --no-dev"
2118
fi
2219

23-
echo "PHP_VERSION $TARGET_PHP_VERSION"
20+
# Install project dependencies
21+
echo "::group::Installing project dependencies"
22+
# shellcheck disable=SC2086
23+
composer install ${COMPOSER_FLAGS}
24+
echo "::endgroup::"
25+
26+
# Build PHPArkitect flags
27+
PHPARKITECT_FLAGS=""
28+
if [ -n "${PHP_VERSION}" ]; then
29+
PHPARKITECT_FLAGS="--target-php-version=${PHP_VERSION}"
30+
echo "::notice::Analyzing code for PHP ${PHP_VERSION} compatibility"
31+
fi
2432

25-
COMPOSER_COMMAND="composer install --no-progress $NO_DEV $IGNORE_PLATFORM_REQS"
26-
echo "::group::$COMPOSER_COMMAND"
27-
$COMPOSER_COMMAND
33+
# Execute PHPArkitect with all arguments
34+
echo "::group::Running PHPArkitect"
35+
# shellcheck disable=SC2086
36+
phparkitect "$@" ${PHPARKITECT_FLAGS}
2837
echo "::endgroup::"
29-
/composer/vendor/bin/phparkitect $* $TARGET_PHP_VERSION

0 commit comments

Comments
 (0)