-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (55 loc) · 2.1 KB
/
generate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Checkout client to subdirectory
uses: actions/checkout@v3
with:
repository: 'mittwald/api-client-php'
path: '.work'
token: ${{ secrets.MACHINE_USER_TOKEN }}
fetch-tags: true
fetch-depth: "0"
- name: Purge previous generated code
run: rm -rf .work/src/Generated
- name: Generate client
run: php ./cmd/generate.php generate https://api.mittwald.de/openapi ./.work -v
- name: Run code formatting on generated client
working-directory: .work
run: |
composer install --prefer-dist --no-progress --no-suggest
composer run format
composer run check
- run: git status
working-directory: .work
- name: Create and push commit
working-directory: .work
env:
GH_TOKEN: ${{ secrets.MACHINE_USER_TOKEN }}
run: |
set -ex
if [[ $(git status --porcelain | wc -l) -eq 0 ]]; then
echo "No changes detected, skipping commit."
exit 0
fi
git config --global user.name "mittwald-machine"
git config --global user.email "[email protected]"
git add src
git commit -m "Update generated client"
last_tag=$(git describe --abbrev=0 --tags)
new_tag=$(php ../cmd/generate.php version "${last_tag}")
git tag -m "Release ${new_tag}" ${new_tag}
git remote add publish "https://mittwald-macine:${{ secrets.MACHINE_USER_TOKEN }}@github.com/mittwald/api-client-php.git"
git push publish
git push --tags publish
gh release create --verify-tag --generate-notes --latest -R mittwald/api-client-php "${new_tag}"