Repository navigation
78 lines (68 loc) · 2.38 KB
/
Copy pathopenapi.yml
File metadata and controls
78 lines (68 loc) · 2.38 KB
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
71
72
73
74
75
76
77
78
name: Publish OpenAPI Snapshot
on:
release:
types: [published]
workflow_dispatch:
permissions:
actions: read
contents: read
packages: read
jobs:
export-openapi:
if: >-
github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false
runs-on: >-
${{ github.event.repository.visibility == 'public'
&& 'ubuntu-24.04'
|| 'grounds-runners' }}
timeout-minutes: 30
steps:
- name: Check out source
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- name: Set up Java
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: "25"
cache: gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Configure GitHub Packages credentials
run: |
mkdir -p ~/.gradle
{
echo "github.user=${{ github.actor }}"
echo "github.token=${{ secrets.PACKAGES_TOKEN || secrets.GITHUB_TOKEN }}"
} > ~/.gradle/gradle.properties
- name: Generate OpenAPI snapshot
run: ./gradlew generateOpenApiSnapshot
# A snapshot with anything else beside it means the build wrote more than the schema, and
# whatever that is would be published as an API description.
- name: Verify snapshot artifact
run: |
snapshot_files="$(find build/api-reference -maxdepth 1 -type f -printf '%f\n')"
if [[ "$snapshot_files" != "openapi.json" ]]; then
echo "OpenAPI snapshot artifact has unexpected contents" >&2
exit 1
fi
- name: Upload OpenAPI snapshot
uses: actions/upload-artifact@v7
with:
name: openapi-snapshot
path: build/api-reference/openapi.json
if-no-files-found: error
retention-days: 1
publish-openapi:
needs: export-openapi
uses: groundsgg/.github/.github/workflows/publish-openapi-snapshot.yml@main
with:
artifact_name: openapi-snapshot
service_id: service-maps
service_title: Maps API
service_slug: maps
source_ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
source_sha: ${{ github.sha }}
secrets:
app_private_key: ${{ secrets.OPENAPI_PUBLISHER_PRIVATE_KEY }}