diff --git a/.github/workflows/check-api-versions.yaml b/.github/workflows/check-api-versions.yaml new file mode 100644 index 0000000..485d8a7 --- /dev/null +++ b/.github/workflows/check-api-versions.yaml @@ -0,0 +1,37 @@ +name: Check API version lock + +on: + # run after PR merge + push: + branches: ["main"] + # run every night at 01:00 + schedule: + - cron: "0 1 * * *" + +env: + THRESHOLD: "10 days ago" + +jobs: + main-go: + name: "[Go] Update SDK Repo" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check commit date + run: | + set -eo pipefail + + THRESHOLD="10 minutes ago" + + if jq -e 'map_values(select(. != "main")) != {}' api-versions-lock.json; then + thresholdDate=$(date -Iminutes -d "${THRESHOLD}") + commitDate=$(git -P log -n 1 --format="%aI" api-versions-lock.json) + if [[ "$commitDate" < "$thresholdDate" ]]; then + echo "latest commit of api-versions-lock.json is older than ${THRESHOLD}" + exit 1 + fi + echo "api-versions-lock.json contains locked versions but is recent enough" + else + echo "no locked versions in api-versions-lock.json" + fi diff --git a/README.md b/README.md index 6be8002..72666fd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Check API version lock](https://github.com/stackitcloud/stackit-sdk-generator/actions/workflows/check-api-versions.yaml/badge.svg)](https://github.com/stackitcloud/stackit-sdk-generator/actions/workflows/check-api-versions.yaml) + # Overview This repository implements the automatic generation of client libraries to access STACKIT APIs. It is based on the [OpenAPI Generator](https://openapi-generator.tech/). The process' input are the REST API specs in the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) format (OAS), which are stored in [STACKIT API specifications](https://github.com/stackitcloud/stackit-api-specifications).