From 71e6c15c8cf5be16a7e52db02fd24a358e7cf27b Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Thu, 16 Oct 2025 23:29:33 +0200 Subject: [PATCH] Create PRs in new site repo - use app token for authentication - spec name in head branch name to avoid collisions between specs - base branch is main - align reviewers with TSC and OpenAPI-maintainers teams - remove mentions of gh-pages in other files --- .github/pull_request_template.md | 2 - .github/workflows/respec.yaml | 86 +++++++++++++------------ .github/workflows/schema-publish.yaml | 90 +++++++++++++++------------ scripts/schema-publish.sh | 13 ++-- 4 files changed, 102 insertions(+), 89 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 16a3c3dc72..6822827b0f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,8 +8,6 @@ present on the main branch, only on the development branches). * 3.1.x spec and schemas: v3.1-dev branch * 3.2.x spec and schemas: v3.2-dev branch * 3.3.x spec and schemas: v3.3-dev branch -* registry templates: gh-pages branch, registry/... -* registry contents: gh-pages branch, registries/... * process documentation and build infrastructure: main Note that we do not accept changes to published specifications. diff --git a/.github/workflows/respec.yaml b/.github/workflows/respec.yaml index 81199c1bf5..3817114bdc 100644 --- a/.github/workflows/respec.yaml +++ b/.github/workflows/respec.yaml @@ -1,11 +1,10 @@ name: respec -# author: @MikeRalphson +# author: @MikeRalphson, @ralfhandl # issue: https://github.com/OAI/OpenAPI-Specification/issues/1564 # -# This workflow updates the respec 'pretty' rendered versions of the spec -# on the gh-pages branch when the corresponding markdown files change. +# This workflow creates a pull request for publishing HTML spec versions to the spec.openapis.org site. # # run this manually from main @@ -19,41 +18,50 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 # checkout main branch - with: - fetch-depth: 0 - - - uses: actions/setup-node@v5 # setup Node.js - with: - node-version: '20.x' - - - name: Install dependencies - run: npm ci - - - uses: actions/checkout@v5 # checkout gh-pages branch - with: - ref: gh-pages - path: deploy - - - name: run main script - run: scripts/md2html/build.sh - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: update-respec-version - base: gh-pages - delete-branch: true - path: deploy - labels: Housekeeping - reviewers: earth2marsh,lornajane,mikekistler,miqui,ralfhandl,handrews,karenetheridge - title: Update ReSpec-rendered specification versions - commit-message: Update ReSpec-rendered specification versions - signoff: true - body: | - This pull request is automatically triggered by GitHub action `respec`. - - The `versions/*.md` files have changed, so the HTML files are automatically being regenerated. + - name: Generate access token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} + private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }} + owner: OAI + repositories: spec.openapis.org + - uses: actions/checkout@v5 # checkout main branch of this repo + with: + fetch-depth: 0 + - uses: actions/setup-node@v5 # setup Node.js + with: + node-version: "22.x" + + - name: Install dependencies + run: npm ci + + - uses: actions/checkout@v5 # checkout main branch of website repo + with: + token: ${{ steps.generate-token.outputs.token }} + repository: OAI/spec.openapis.org + ref: main + path: deploy + + - name: run main script + run: scripts/md2html/build.sh + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.generate-token.outputs.token }} + branch: openapi-spec-versions + base: main + delete-branch: true + path: deploy + labels: OpenAPI,Specification + reviewers: earth2marsh,lornajane,mikekistler,miqui,ralfhandl,whitlockjc,handrews,karenetheridge + title: OpenAPI - update ReSpec-rendered specification versions + commit-message: Update ReSpec-rendered specification versions + signoff: true + body: | + This pull request is automatically generated by GitHub action `respec` in the OAI/OpenAPI-Specification repo. + + The `versions/*.md` files of the OpenAPI Specification have changed and the corresponding HTML files are regenerated. diff --git a/.github/workflows/schema-publish.yaml b/.github/workflows/schema-publish.yaml index 33d719c636..178016573e 100644 --- a/.github/workflows/schema-publish.yaml +++ b/.github/workflows/schema-publish.yaml @@ -4,58 +4,66 @@ name: schema-publish # issue: https://github.com/OAI/OpenAPI-Specification/issues/3715 # -# This workflow creates a pull request for publishing schema iterations to the gh-pages branch +# This workflow creates a pull request for publishing schema iterations to the spec.openapis.org site. # # run this on push to vX.Y-dev branches or manually on: push: branches: - - 'v[0-9].[0-9]-dev' + - "v[0-9].[0-9]-dev" paths: - - 'src/schemas/validation/*.yaml' - - 'scripts/schema-publish.sh' - - '.github/workflows/schema-publish.yaml' + - "src/schemas/validation/*.yaml" workflow_dispatch: {} jobs: publish: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 # checkout main branch - with: - fetch-depth: 0 - - - uses: actions/setup-node@v5 # setup Node.js - with: - node-version: '22.x' - - - name: Install dependencies - run: npm ci - - - uses: actions/checkout@v5 # checkout gh-pages branch - with: - ref: gh-pages - path: deploy - - - name: run main script - run: scripts/schema-publish.sh - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref_name }}-publish-schema-iteration - base: gh-pages - delete-branch: true - path: deploy - labels: Housekeeping,Schema - reviewers: darrelmiller,webron,earth2marsh,lornajane,mikekistler,miqui,ralfhandl,handrews,karenetheridge - title: '${{ github.ref_name }}: publish OpenAPI schema iterations' - commit-message: New OpenAPI schema iterations - signoff: true - body: | - This pull request is automatically generated by GitHub action `schema-publish`. - The `src/schemas/validation/*.yaml` files have changed and JSON files are automatically generated. + - name: Generate access token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} + private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }} + owner: OAI + repositories: spec.openapis.org + + - uses: actions/checkout@v5 # checkout main branch of this repo + with: + fetch-depth: 0 + + - uses: actions/setup-node@v5 # setup Node.js + with: + node-version: "22.x" + + - name: Install dependencies + run: npm ci + + - uses: actions/checkout@v5 # checkout main branch of website repo + with: + token: ${{ steps.generate-token.outputs.token }} + repository: OAI/spec.openapis.org + ref: main + path: deploy + + - name: run main script + run: scripts/schema-publish.sh + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.generate-token.outputs.token }} + branch: openapi-${{ github.ref_name }}-schema-iterations + base: main + delete-branch: true + path: deploy + labels: OpenAPI,Schema + reviewers: earth2marsh,lornajane,mikekistler,miqui,ralfhandl,whitlockjc,handrews,karenetheridge + title: "OpenAPI - publish ${{ github.ref_name }} schema iterations" + commit-message: "New OpenAPI schema iterations published from ${{ github.ref_name }}" + signoff: true + body: | + This pull request is automatically generated by GitHub action `schema-publish` in the OAI/OpenAPI-Specification repo. + The `src/schemas/validation/*.yaml` files have changed and JSON files are automatically generated. diff --git a/scripts/schema-publish.sh b/scripts/schema-publish.sh index bfc522b28c..764e73a8f0 100755 --- a/scripts/schema-publish.sh +++ b/scripts/schema-publish.sh @@ -37,19 +37,18 @@ publish_schema() { # replace the WORK-IN-PROGRESS placeholders sed ${sedCmd[@]} $schemaDir/$schema | npx yaml --json --indent 2 --single > $target - # Find the jekyll lander markdown file for this version. + # find the jekyll lander markdown file local jekyllLander=$(find "$deploydir/$base" -maxdepth 1 -name "*.md") - # Move the jekyll lander markdown for this iteration to the deploy destination. - # The lander files only exist in the gh-pages branch. + # rename or create the jekyll lander markdown file for this iteration if [ ! -z "$jekyllLander" ]; then mv $jekyllLander $target.md echo " * $newestCommitDate: $schema & jekyll lander $(basename $jekyllLander)" else - # Find the most recent preceding version. + # find the most recent preceding version local lastdir=""; for fn in $(dirname $deploydir)/?.?; do test "$fn" "<" "$deploydir" && lastdir="$fn"; done local lastVersion=$(basename $lastdir) - # Find the jekyll lander markdown file for the preceding version. + # find the jekyll lander markdown file for the preceding version local lastLander=$(find "$lastdir/$base" -maxdepth 1 -name "*.md") if [ ! -z "$lastLander" ]; then @@ -68,7 +67,7 @@ echo === Building schemas into $deploydir # list of schemas to process, dependent schemas come first schemas=(meta.yaml dialect.yaml schema.yaml schema-base.yaml) -# publish each schema using its or any of its dependencies newest commit date. +# publish each schema using its or any of its dependencies newest commit date maxDate="" sedCmds=() for schema in "${schemas[@]}"; do @@ -81,7 +80,7 @@ for schema in "${schemas[@]}"; do fi base=$(basename $schema '.yaml') - # Add the replacement for this schema's placeholder to list of sed commands. + # add the replacement for this schema's placeholder to list of sed commands sedCmds+=("s/${base}\/WORK-IN-PROGRESS/${base}\/${maxDate}/g") publish_schema "$schema" "$maxDate" $(printf '%s;' "${sedCmds[@]}")