Skip to content
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
9 changes: 0 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ jobs:

- name: Check for uncommitted changes
run: ./scripts/assert-clean-working-directory.sh

- name: Publish documentation
if: github.ref == 'refs/heads/main'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
yarn lerna run publish:gh-pages --scope '@nahkies/openapi-code-generator-documentation'

# TODO: figure out how to do this safely, eg: no risk of external contributors exfiltrating publish secret.
# - name: Configure Git User
# run: |
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish Docs
on:
push:
tags:
- v*

jobs:
publish_docs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24.x]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
registry-url: "https://registry.npmjs.org"
node-version: ${{ matrix.node-version }}

- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
id: yarn-cache
with:
path: .yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
id: nextjs-cache
with:
path: packages/documentation/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-

- run: corepack enable

- run: yarn --immutable
- run: yarn ci-build
- name: Publish documentation
if: github.ref == 'refs/heads/main'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
yarn lerna run publish:gh-pages --scope '@nahkies/openapi-code-generator-documentation'
Comment on lines +9 to +51

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 12 months ago

To fix the issue, we will add a permissions block at the workflow level to explicitly define the least privileges required. Based on the workflow's actions:

  • The contents: write permission is needed for publishing documentation (lines 48-51).
  • No other permissions appear to be required.

The permissions block will be added at the root level of the workflow, ensuring it applies to all jobs unless overridden.


Suggested changeset 1
.github/workflows/publish-docs.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml
--- a/.github/workflows/publish-docs.yml
+++ b/.github/workflows/publish-docs.yml
@@ -1,2 +1,4 @@
 name: Publish Docs
+permissions:
+  contents: write
 on:
EOF
@@ -1,2 +1,4 @@
name: Publish Docs
permissions:
contents: write
on:
Copilot is powered by AI and may make mistakes. Always verify output.