Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenAPI Specification to Release Assets #9054

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/fetch-oas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Fetch OpenAPI Specifications

Check warning on line 1 in .github/workflows/fetch-oas.yml

View check run for this annotation

DryRunSecurity / AI-powered Sensitive Files Check

Possible Sensitive File

Our AI-Powered Sensitive File checker believes it has discovered a sensitive file being modified in this PR. Extra care must be taken when modifying a file that is potentially security-sensitive. The following reason was provided: This file is classified as sensitive because it contains workflows related to fetching OpenAPI specifications (OAS), which may include sensitive information such as API keys, endpoints, or authentication credentials.

on:
workflow_call:

jobs:
oas_fetch:
name: Fetch OpenAPI Specifications
runs-on: ubuntu-latest
strategy:
matrix:
file-type: [yaml, json]
steps:
- name: Checkout
uses: actions/checkout@v4

# load docker images from build jobs
- name: Load images from artifacts
uses: actions/download-artifact@v3

- name: Load docker images
run: |-
docker load -i nginx/nginx-alpine_img
docker load -i django/django-alpine_img
docker images

- name: Start Dojo
run: docker-compose --profile postgres-redis --env-file ./docker/environments/postgres-redis.env up --no-deps -d postgres nginx uwsgi
env:
DJANGO_VERSION: alpine
NGINX_VERSION: alpine

- name: Download OpenAPI Specifications
run: |-
wget 'http://localhost:8080/api/v2/oa3/schema/?format=${{ matrix.file-type }}' -O oas.${{ matrix.file-type }} --tries=10 --retry-on-http-error=502

- name: Logs
if: always()
run: docker-compose --profile postgres-redis --env-file ./docker/environments/postgres-redis.env logs --tail="2500"

- name: Shutdown
if: always()
run: docker-compose --profile postgres-redis --env-file ./docker/environments/postgres-redis.env down

- name: Upload oas.${{ matrix.file-type }} as artifact
uses: actions/upload-artifact@v3
with:
name: oas-${{ matrix.file-type }}
path: oas.${{ matrix.file-type }}
retention-days: 1
39 changes: 38 additions & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Drafter

Check warning on line 1 in .github/workflows/release-drafter.yml

View check run for this annotation

DryRunSecurity / AI-powered Sensitive Files Check

Possible Sensitive File

Our AI-Powered Sensitive File checker believes it has discovered a sensitive file being modified in this PR. Extra care must be taken when modifying a file that is potentially security-sensitive. The following reason was provided: This file is classified as sensitive because it contains workflows related to release drafting, which may include sensitive information such as version numbers, release notes, or other internal project details.

on:
workflow_dispatch:
Expand All @@ -16,11 +16,48 @@
- dev

jobs:
build-docker-containers:
uses: ./.github/workflows/build-docker-images-for-testing.yml
secrets: inherit

oas-fetch:
needs: build-docker-containers
uses: ./.github/workflows/fetch-oas.yml
secrets: inherit

update_release_draft:
needs: oas-fetch
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5.25.0
- name: Load OAS files from artifacts
uses: actions/download-artifact@v3

- name: Create Release
id: create_release
uses: release-drafter/release-drafter@v5.25.0
with:
version: ${{github.event.inputs.version}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset - OpenAPI Specification - YAML
id: upload-release-asset-yaml
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oas-yaml/oas.yaml
asset_name: oas.yaml
asset_content_type: application/vnd.oai.openapi

- name: Upload Release Asset - OpenAPI Specification - JSON
id: upload-release-asset-json
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oas-json/oas.json
asset_name: oas.json
asset_content_type: application/json