initial commit
This commit is contained in:
66
.gitea/workflows/weekly.yaml
Normal file
66
.gitea/workflows/weekly.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Update Client
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "@weekly"
|
||||
|
||||
jobs:
|
||||
update-client:
|
||||
runs-on:
|
||||
- ubuntu-latest
|
||||
- linux_amd64
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23.5"
|
||||
- name: Install yq
|
||||
run: |
|
||||
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
|
||||
sudo chmod +x /usr/bin/yq
|
||||
- name: Install openapi codegen
|
||||
run: go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1
|
||||
- name: Download Ionos DNS OpenAPI Spec
|
||||
run: curl -sL https://developer.hosting.ionos.com/assets/kms-swagger-specs/dns.yaml -o openapi.yaml
|
||||
- name: Compare OpenAPI Versions
|
||||
id: version_check
|
||||
run: |
|
||||
NEW_VERSION=$(yq -r '.info.version' openapi.yaml)
|
||||
if [ -f openapi_spec.yaml ]; then
|
||||
OLD_VERSION=$(yq -r '.info.version' openapi_spec.yaml)
|
||||
else
|
||||
OLD_VERSION="0.0.0"
|
||||
fi
|
||||
echo "New Version: $NEW_VERSION"
|
||||
echo "Old Version: $OLD_VERSION"
|
||||
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
|
||||
echo "New version detected"
|
||||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
|
||||
else
|
||||
echo "No new version detected"
|
||||
exit 0
|
||||
fi
|
||||
- name: Generate OpenAPI Client
|
||||
if: env.NEW_VERSION
|
||||
run: |
|
||||
rm -rf *.go
|
||||
oapi-codegen --config cfg.yaml openapi.yaml
|
||||
go mod tidy
|
||||
- name: Update Local OpenAPI Spec
|
||||
if: env.NEW_VERSION
|
||||
run: mv openapi.yaml openapi_spec.yaml
|
||||
- name: Commit and Push Changes
|
||||
if: env.NEW_VERSION
|
||||
run: |
|
||||
git config user.name "OpenAPI Bot"
|
||||
git config user.email "t.behrendt@t00n.de"
|
||||
git add .
|
||||
git commit -m "Update OpenAPI client to version $NEW_VERSION"
|
||||
git push
|
||||
- name: Create Tag
|
||||
if: env.NEW_VERSION
|
||||
run: |
|
||||
git tag -a "v$NEW_VERSION" -m "Update OpenAPI client to version $NEW_VERSION"
|
||||
git push origin "v$NEW_VERSION"
|
||||
Reference in New Issue
Block a user