Skip to content

feat: implement the metadata query #177

feat: implement the metadata query

feat: implement the metadata query #177

Workflow file for this run

name: Redocly openapi generate
on:
push:
# paths:
# - "docs/api.yaml"
# - "docs/**"
pull_request:
jobs:
generate:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/987979088361/locations/global/workloadIdentityPools/github/providers/github-action
service_account: [email protected]
create_credentials_file: true
- name: Install Redocly CLI
run: npm install -g @redocly/cli@latest
- name: Run linting
id: lint
run: |
redocly lint docs/api.yaml --format=github-actions
redocly lint docs/api.yaml --format=markdown > result.md
result="$(cat result.md | base64 -w 0)"
echo "result=$result" >> $GITHUB_OUTPUT
- name: Run bundle
run: redocly bundle docs/api.yaml --output=openapi.yaml
- id: hash
name: Get bundle file hash
run: echo "hash=$(sha256sum openapi.yaml | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
# upload to gcs
- name: upload-file
uses: google-github-actions/upload-cloud-storage@v2
with:
path: openapi.yaml
destination: rss3-openapi/${{ steps.hash.outputs.hash }}
process_gcloudignore: 'false'
# get current pr
- name: Get PR
id: get-pr
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
# comment to
- name: comment url
uses: actions/github-script@v7
continue-on-error: true
with:
github-token: '${{ github.token }}'
script: |
const result = Buffer.from('${{ steps.lint.outputs.result }}', 'base64').toString('utf-8');
const body = `commit hash: ${context.sha}
[openapi.yaml](https://petstore.swagger.io/?url=https://storage.googleapis.com/rss3-openapi/${{ steps.hash.outputs.hash }}/openapi.yaml)
# Lint Result
${result}
`;
github.rest.issues.createComment({
issue_number: '${{ fromJson(steps.get-pr.outputs.result).number }}',
owner: context.repo.owner,
repo: context.repo.repo,
body,
})