Skip to content

Commit 52856b7

Browse files
authored
Initial commit
0 parents  commit 52856b7

38 files changed

+2032
-0
lines changed

.github/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
updates:
3+
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: "github-actions"
6+
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
7+
directory: "/"
8+
schedule:
9+
interval: "weekly"
10+
assignees:
11+
- cedricziel
12+
commit-message:
13+
prefix: "fix: "
14+
15+
- package-ecosystem: "composer"
16+
directory: "/"
17+
schedule:
18+
interval: "weekly"
19+
assignees:
20+
- cedricziel
21+
commit-message:
22+
prefix: "fix: "
23+
- package-ecosystem: "composer"
24+
directory: ".github/template-cleanup"
25+
schedule:
26+
interval: "weekly"
27+
assignees:
28+
- cedricziel
29+
commit-message:
30+
prefix: "fix: "

.github/template-cleanup/.gitkeep

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return [
4+
'openapi-file' => __DIR__ . '/openapi.json',
5+
'namespace' => 'myvendor\mynamespace\Generated',
6+
'directory' => __DIR__ . '/generated',
7+
'use-fixer' => true,
8+
];

.github/template-cleanup/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# %NAME%
2+
3+
An API client.
4+
5+
## Next steps
6+
7+
- [x] Use the template to kickstart your repository
8+
- [ ] Add your OpenAPI spec to `openapi.json`. The client will be regenerated every time you push to the repository
9+
- [ ] Add your LICENSE to the project
10+
- [ ] Add a release-please token secret as `MY_RELEASE_PLEASE_TOKEN` to the repository to benefit from automatic releases
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "myvendor/mynamespace",
3+
"description": "An API client",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"myvendor\\mynamespace\\": "src/",
9+
"myvendor\\mynamespace\\Generated\\": "generated/"
10+
}
11+
},
12+
"authors": [
13+
{
14+
"name": "myvendor",
15+
"email": "mail@example.com"
16+
}
17+
],
18+
"require-dev": {
19+
"jane-php/open-api-3": "^7.8",
20+
"friendsofphp/php-cs-fixer": "^3.59"
21+
},
22+
"config": {
23+
"allow-plugins": {
24+
"php-http/discovery": true
25+
}
26+
},
27+
"require": {
28+
"php": "^8.3",
29+
"jane-php/open-api-runtime": "^7.8"
30+
},
31+
"extra": {
32+
"symfony": {
33+
"allow-contrib": "true"
34+
}
35+
}
36+
}

.github/workflows/client-generate.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Generate API client
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: write
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- run: npm i -g @redocly/cli@latest
20+
- run: redocly lint openapi.json
21+
22+
build:
23+
name: Generate Client
24+
needs:
25+
- lint
26+
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Setup PHP with PECL extension
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: '8.3'
36+
37+
- name: Validate composer.json and composer.lock
38+
run: composer validate --strict
39+
40+
- name: Cache Composer packages
41+
id: composer-cache
42+
uses: actions/cache@v4
43+
with:
44+
path: vendor
45+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
46+
restore-keys: |
47+
${{ runner.os }}-php-
48+
49+
- name: Install dependencies
50+
run: composer install --prefer-dist --no-progress
51+
52+
- name: Generate API client
53+
run: php vendor/bin/jane-openapi generate
54+
55+
- name: Run php-cs-fixer
56+
uses: docker://oskarstark/php-cs-fixer-ga
57+
58+
- uses: stefanzweifel/git-auto-commit-action@v5
59+
with:
60+
commit_message: Apply php-cs-fixer changes
61+
62+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
63+
# Docs: https://getcomposer.org/doc/articles/scripts.md
64+
65+
# - name: Run test suite
66+
# run: composer run-script test

.github/workflows/php.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- run: npm i -g @redocly/cli@latest
22+
- run: redocly lint openapi.json
23+
- name: Run php-cs-fixer
24+
uses: docker://oskarstark/php-cs-fixer-ga
25+
build:
26+
needs:
27+
- lint
28+
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Setup PHP with PECL extension
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: '8.3'
38+
39+
- name: Validate composer.json and composer.lock
40+
run: composer validate --strict
41+
42+
- name: Cache Composer packages
43+
id: composer-cache
44+
uses: actions/cache@v4
45+
with:
46+
path: vendor
47+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
48+
restore-keys: |
49+
${{ runner.os }}-php-
50+
51+
- name: Install dependencies
52+
run: composer install --prefer-dist --no-progress
53+
54+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
55+
# Docs: https://getcomposer.org/doc/articles/scripts.md
56+
57+
# - name: Run test suite
58+
# run: composer run-script test

.github/workflows/release-please.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
name: release-please
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: googleapis/release-please-action@v4
17+
with:
18+
# this assumes that you have created a personal access token
19+
# (PAT) and configured it as a GitHub action secret named
20+
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
21+
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
22+
# this is a built-in strategy in release-please, see "Action Inputs"
23+
# for more options
24+
release-type: simple

.github/workflows/semantic-pr.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Lint PR"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
- reopened
10+
11+
permissions:
12+
pull-requests: read
13+
14+
jobs:
15+
main:
16+
name: Validate PR title
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: amannn/action-semantic-pull-request@v5
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# GitHub Actions Workflow responsible for cleaning up the IntelliJ Platform Plugin Template repository from the template-specific files and configurations.
2+
# This workflow is supposed to be triggered automatically when a new template-based repository has been created.
3+
# Source: https://github.com/JetBrains/intellij-platform-plugin-template/blob/main/.github/workflows/template-cleanup.yml
4+
5+
name: Template Cleanup
6+
on:
7+
push:
8+
branches: [main]
9+
10+
jobs:
11+
12+
# Run a cleaning process only if the workflow is triggered by the non-"php-openapi-client-template" repository.
13+
template-cleanup:
14+
name: Template Cleanup
15+
runs-on: ubuntu-latest
16+
if: github.event.repository.name != 'php-openapi-client-template'
17+
permissions:
18+
contents: write
19+
steps:
20+
21+
# Check out the current repository
22+
- name: Fetch Sources
23+
uses: actions/checkout@v4
24+
25+
# Cleanup project
26+
- name: Cleanup
27+
run: |
28+
export LC_CTYPE=C
29+
export LANG=C
30+
31+
# Prepare variables
32+
NAME="${GITHUB_REPOSITORY##*/}"
33+
ACTOR=$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')
34+
SAFE_NAME=$(echo $NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
35+
SAFE_ACTOR=$(echo $ACTOR | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
36+
37+
# Replace placeholders in the template-cleanup files
38+
sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/*
39+
sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" .github/template-cleanup/*
40+
41+
find src -type f -exec sed -i "s/myvendor/$SAFE_ACTOR/g" {} +
42+
find src -type f -exec sed -i "s/mynamespace/$SAFE_NAME/g" {} +
43+
44+
find .github/template-cleanup -type f -exec sed -i "s/myvendor/$SAFE_ACTOR/g" {} +
45+
find .github/template-cleanup -type f -exec sed -i "s/mynamespace/$SAFE_NAME/g" {} +
46+
47+
# Move content
48+
cp -R .github/template-cleanup/. .
49+
50+
# Cleanup
51+
rm -rf \
52+
.github/template-cleanup \
53+
.github/workflows/template-cleanup.yml \
54+
LICENSE
55+
56+
# Commit modified files
57+
- name: Commit files
58+
run: |
59+
git config --local user.email "action@github.com"
60+
git config --local user.name "GitHub Action"
61+
git add .
62+
git commit -m "Template cleanup"
63+
64+
# Push changes
65+
- name: Push changes
66+
uses: ad-m/github-push-action@master
67+
with:
68+
branch: main
69+
github_token: ${{ secrets.GITHUB_TOKEN }}
70+
71+
generate:
72+
name: Initial client generation
73+
needs:
74+
- template-cleanup
75+
76+
runs-on: ubuntu-latest
77+
if: github.event.repository.name != 'php-openapi-client-template'
78+
permissions:
79+
contents: write
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: Setup PHP with PECL extension
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: '8.3'
88+
89+
- name: Validate composer.json and composer.lock
90+
run: composer validate --strict
91+
92+
- name: Cache Composer packages
93+
id: composer-cache
94+
uses: actions/cache@v4
95+
with:
96+
path: vendor
97+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
98+
restore-keys: |
99+
${{ runner.os }}-php-
100+
101+
- name: Install dependencies
102+
run: composer install --prefer-dist --no-progress
103+
104+
- name: Generate API client
105+
run: php vendor/bin/jane-openapi generate
106+
107+
- name: Run php-cs-fixer
108+
uses: docker://oskarstark/php-cs-fixer-ga
109+
110+
- uses: stefanzweifel/git-auto-commit-action@v5
111+
with:
112+
commit_message: Apply php-cs-fixer changes

0 commit comments

Comments
 (0)