.github/workflows/generate.yml #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Generate client | |
run: php ./cmd/generate.php generate https://api.mittwald.de/openapi ./.work -v | |
- run: git status | |
working-directory: .work | |
- name: Create and push commit | |
working-directory: .work | |
env: | |
GH_TOKEN: ${{ secrets.MACHINE_USER_TOKEN }} | |
run: | | |
set -ex | |
composer install --prefer-dist --no-progress --no-suggest | |
vendor/bin/psalm | |
composer run format | |
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}" |