Skip to content

Commit 9b50154

Browse files
florentsorelclaude
andauthored
chore(ci): publish the image to ghcr.io, and drop the unused action wrapper [FTTECH-15150] (#11)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ee4e8c8 commit 9b50154

10 files changed

Lines changed: 212 additions & 84 deletions

File tree

‎.dockerignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
README.md
2-
examples
1+
*
2+
!entrypoint.sh

‎.github/workflows/closed.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
ZapierReviewRequestedPurpleHeart:
1313
if: github.event.pull_request.merged == true
1414
name: "Zapier Purple Heart"
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-slim
1616
timeout-minutes: 1
1717
steps:
1818
- name: "Sync emoji in #mobsuccess-review-requested"
@@ -21,7 +21,7 @@ jobs:
2121
ZapierReviewRequestedRedCross:
2222
if: github.event.pull_request.merged == false
2323
name: "Zapier Red Cross"
24-
runs-on: ubuntu-20.04
24+
runs-on: ubuntu-slim
2525
timeout-minutes: 1
2626
steps:
2727
- name: "Sync emoji in #mobsuccess-review-requested"
@@ -30,7 +30,7 @@ jobs:
3030
CommentSubPRs:
3131
if: github.event.pull_request.merged == true
3232
name: "Comment rebase --onto on Sub PRs"
33-
runs-on: ubuntu-20.04
33+
runs-on: ubuntu-slim
3434
timeout-minutes: 2
3535
steps:
3636
- uses: mobsuccess-devops/github-actions-mobsuccess@master

‎.github/workflows/docker.yml‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Docker
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- "Dockerfile"
8+
- "entrypoint.sh"
9+
- ".github/workflows/docker.yml"
10+
push:
11+
branches: [master]
12+
paths:
13+
- "Dockerfile"
14+
- "entrypoint.sh"
15+
- ".github/workflows/docker.yml"
16+
workflow_dispatch:
17+
18+
env:
19+
REGISTRY: ghcr.io
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
jobs:
23+
build:
24+
name: Build Docker image
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 15
27+
permissions:
28+
contents: read
29+
packages: write
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v7
33+
34+
- name: PHP-CS-Fixer version
35+
id: version
36+
run: echo "version=$(sed -n 's/^ARG PHP_CS_FIXER_VERSION=//p' Dockerfile)" >> "$GITHUB_OUTPUT"
37+
38+
- name: Log in to Container Registry
39+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
40+
uses: docker/login-action@v4
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Docker metadata
47+
id: meta
48+
uses: docker/metadata-action@v6
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
tags: |
52+
type=raw,value=v${{ steps.version.outputs.version }},enable={{is_default_branch}}
53+
type=sha,format=long
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v4
57+
58+
- name: Build and push
59+
uses: docker/build-push-action@v7
60+
with:
61+
context: .
62+
platforms: linux/amd64
63+
push: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' }}
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max

‎.github/workflows/mobsuccess.yml‎

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
name: Mobsuccess Compliance
66

77
on:
8+
merge_group:
9+
types:
10+
- checks_requested
11+
12+
issue_comment:
13+
types:
14+
- created
15+
- edited
16+
817
pull_request:
918
types:
1019
- opened
@@ -14,13 +23,101 @@ on:
1423
jobs:
1524
MobsuccessPRCompliance:
1625
name: "Mobsuccess PR Compliance"
17-
runs-on: ubuntu-20.04
26+
runs-on: ubuntu-slim
1827
timeout-minutes: 2
1928
steps:
2029
- uses: mobsuccess-devops/github-actions-mobsuccess@master
2130
with:
2231
github-token: ${{ github.token }}
23-
amplify-uri: ${{ secrets.AWS_AMPLIFY_URI }}
24-
storybook-amplify-uri: ${{ secrets.AWS_STORYBOOK_AMPLIFY_URI }}
32+
amplify-uri: ${{ secrets.AWS_AMPLIFY_URI }}${{ vars.AWS_AMPLIFY_URI }}
33+
storybook-amplify-uri: ${{ secrets.AWS_STORYBOOK_AMPLIFY_URI }}${{ vars.AWS_STORYBOOK_AMPLIFY_URI }}
2534
action: "validate-pr"
35+
36+
- name: Checkout
37+
if: github.event_name == 'pull_request'
38+
uses: actions/checkout@v7
39+
with:
40+
fetch-depth: 0
41+
filter: blob:none
42+
43+
- name: Ignored directory replacement
44+
if: github.event_name == 'pull_request'
45+
run: |
46+
set -uo pipefail
47+
fail=0
48+
49+
die() { printf '%s\n' "::error::$(esc "$1")"; exit 1; }
50+
51+
esc() { local s=${1//'%'/%25}; s=${s//$'\r'/%0D}; s=${s//$'\n'/%0A}; printf '%s' "$s"; }
52+
esc_prop() { local s; s=$(esc "$1"); s=${s//:/%3A}; s=${s//,/%2C}; printf '%s' "$s"; }
53+
54+
work=$(mktemp -d)
55+
trap 'rm -rf "$work"' EXIT
56+
57+
git diff --raw -z --no-renames --diff-filter=AMT "$BASE_SHA...$HEAD_SHA" > "$work/diff" \
58+
|| die "Cannot diff $BASE_SHA...$HEAD_SHA. Refusing to pass without having checked."
59+
git ls-tree -r -z --name-only "$HEAD_SHA" > "$work/tree" \
60+
|| die "Cannot list the tree at $HEAD_SHA. Refusing to pass without having checked."
61+
62+
sandbox="$work/sandbox"
63+
mkdir -p "$sandbox"
64+
git -C "$sandbox" init -q .
65+
66+
: > "$sandbox/.git/info/exclude"
67+
ignored() {
68+
git -c core.excludesFile=/dev/null -C "$sandbox" \
69+
check-ignore -q --no-index -- "$1"
70+
}
71+
72+
while IFS= read -r -d '' gi; do
73+
case "$gi" in .gitignore|*/.gitignore) ;; *) continue ;; esac
74+
mkdir -p "$sandbox/$(dirname "$gi")"
75+
git show "$HEAD_SHA:$gi" > "$sandbox/$gi" \
76+
|| die "Cannot read $gi at $HEAD_SHA. Refusing to pass without having checked."
77+
done < "$work/tree"
78+
79+
while IFS= read -r -d '' meta && IFS= read -r -d '' path; do
80+
mode=$(printf '%s' "$meta" | awk '{print $2}')
81+
case "$mode" in 040000|000000) continue ;; esac
82+
83+
if ! ignored "$path" && ignored "$path/__probe__"; then
84+
kind="file"
85+
if [ "$mode" = "120000" ]; then
86+
t=$(git show "$HEAD_SHA:$path") \
87+
|| die "Cannot read the symlink target of $path at $HEAD_SHA."
88+
kind="symlink -> $t"
89+
fi
90+
printf '%s\n' "::error file=$(esc_prop "$path")::$(esc "Tracking '$path' ($kind) will DELETE the ignored directory of the same name when this is merged or checked out — its contents are gitignored but the path itself is not.")"
91+
fail=1
92+
fi
93+
94+
if [ "$mode" = "120000" ]; then
95+
target=$(git show "$HEAD_SHA:$path") \
96+
|| die "Cannot read the symlink target of $path at $HEAD_SHA."
97+
resolved=$(python3 -c 'import posixpath,sys; print(posixpath.normpath(posixpath.join(posixpath.dirname(sys.argv[1]), sys.argv[2])))' "$path" "$target") \
98+
|| die "Cannot resolve the symlink target of $path."
99+
escape=0
100+
case "$target" in /*) escape=1 ;; esac
101+
case "$resolved" in ..*) escape=1 ;; esac
102+
if [ "$escape" -eq 1 ]; then
103+
printf '%s\n' "::error file=$(esc_prop "$path")::$(esc "Symlink '$path' -> '$target' points outside the repository. Tracked symlinks must stay repo-internal.")"
104+
fail=1
105+
fi
106+
fi
107+
done < "$work/diff"
108+
109+
if [ "$fail" -ne 0 ]; then
110+
echo ""
111+
echo "Remove the offending entry from the commit: git rm --cached <path>"
112+
echo ""
113+
echo "Do NOT 'fix' the .gitignore instead: 'dir/*' plus '!dir/keep' cannot be"
114+
echo "rewritten as a bare 'dir', because git will not re-include anything inside"
115+
echo "an ignored directory. A bare 'dir' is correct only where there is no"
116+
echo "negation to preserve."
117+
exit 1
118+
fi
119+
echo "No ignored-directory replacement detected."
120+
env:
121+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
122+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
26123
# DO NOT EDIT: END

‎Dockerfile‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
FROM --platform=linux/amd64 php:8.1-alpine
1+
FROM php:8.1.34-alpine
22

3-
LABEL "com.github.actions.name"="PHP-CS-Fixer"
4-
LABEL "com.github.actions.description"="check php files"
5-
LABEL "com.github.actions.icon"="check"
6-
LABEL "com.github.actions.color"="blue"
3+
ARG PHP_CS_FIXER_VERSION=3.13.0
4+
ARG PHP_CS_FIXER_SHA256=ac2e57e32cdae67f21baa88f78405f93d4d6e928f41ba62dc91505565c785a44
75

8-
RUN wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.13.0/php-cs-fixer.phar -O php-cs-fixer \
9-
&& chmod a+x php-cs-fixer \
10-
&& mv php-cs-fixer /usr/local/bin/php-cs-fixer
6+
ADD --checksum=sha256:${PHP_CS_FIXER_SHA256} --chmod=755 \
7+
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v${PHP_CS_FIXER_VERSION}/php-cs-fixer.phar \
8+
/usr/local/bin/php-cs-fixer
9+
10+
COPY entrypoint.sh /entrypoint.sh
1111

12-
ADD entrypoint.sh /entrypoint.sh
1312
ENTRYPOINT ["/entrypoint.sh"]

‎README.md‎

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,46 @@
1-
# GithubAction for PHP-CS-Fixer
1+
# github-actions-php-cs-fixer
22

3-
## Usage
3+
A Docker image that runs [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
4+
in a GitHub Actions workflow. Its arguments are passed to `php-cs-fixer fix`.
45

5-
You can use it as a Github Action like this:
6+
## Usage
67

7-
_.github/workflows/lint.yml_
88
```yaml
9-
on: [push, pull_request]
10-
name: Main
119
jobs:
1210
php-cs-fixer:
1311
name: PHP-CS-Fixer
1412
runs-on: ubuntu-latest
1513
steps:
16-
- uses: actions/checkout@v2
17-
- name: PHP-CS-Fixer
18-
uses: docker://oskarstark/php-cs-fixer-ga
14+
- uses: actions/checkout@v7
15+
- name: PHP-CS-Fixer
16+
uses: docker://ghcr.io/mobsuccess-devops/github-actions-php-cs-fixer:v3.13.0
17+
with:
18+
args: --config=.php-cs-fixer.dist.php --diff --dry-run .
1919
```
2020
21-
_to use a custom config for example, --diff and --dry-run option:_
22-
```diff
23-
on: [push, pull_request]
24-
name: Main
25-
jobs:
26-
php-cs-fixer:
27-
name: PHP-CS-Fixer
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v2
31-
- name: PHP-CS-Fixer
32-
uses: docker://oskarstark/php-cs-fixer-ga
33-
+ with:
34-
+ args: --config=.project.php_cs --diff --dry-run
35-
```
21+
The tag is the PHP-CS-Fixer version. Keep it in the workflow: another version
22+
has other rules, and would reformat the code it checks.
3623
37-
**You can copy/paste the .github folder (under examples/) to your project and thats all!**
24+
Locally, from the repository to check:
3825
39-
## Docker
26+
```bash
27+
docker run --rm -v "$PWD:/app" -w /app ghcr.io/mobsuccess-devops/github-actions-php-cs-fixer:v3.13.0 --diff --dry-run .
28+
```
4029

41-
A Docker-Image is built automatically and located here:
42-
https://hub.docker.com/r/oskarstark/php-cs-fixer-ga
30+
## Image
4331

44-
You can run it in any given directory like this:
32+
A push to `master` that changes the `Dockerfile` or `entrypoint.sh` publishes
33+
the image to `ghcr.io/mobsuccess-devops/github-actions-php-cs-fixer`
34+
(`.github/workflows/docker.yml`), tagged with the PHP-CS-Fixer version. The
35+
`Docker` workflow can also be run by hand.
4536

46-
`docker run --rm -it -w=/app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:latest`
37+
Workflows pull it without credentials, so the package has to be public: keep
38+
secrets out of the image. A package is private when first published; someone
39+
with admin rights on it makes it public once (Package settings → Danger Zone →
40+
Change visibility), which cannot be undone.
4741

48-
## A picture is worth a thousand words
42+
To move to another PHP-CS-Fixer version, change `PHP_CS_FIXER_VERSION` and
43+
`PHP_CS_FIXER_SHA256` in the `Dockerfile` (the SHA-256 of the released
44+
`php-cs-fixer.phar`), and the tag in `compose.yml` and in this file.
4945

50-
You can find a working and not working PR here:
51-
https://github.com/OskarStark/test-php-cs-fixer-ga/pulls
46+
To build the image locally: `docker compose build`.

‎action.yml‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎compose.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
php-cs-fixer:
3+
build: .
4+
image: ghcr.io/mobsuccess-devops/github-actions-php-cs-fixer:v3.13.0

‎docker-compose.yml‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎examples/.github/workflows/push.yml‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)