-
Notifications
You must be signed in to change notification settings - Fork 549
ci: fix documentation artefacts automatically after merge #8024
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
base: main
Are you sure you want to change the base?
Changes from all commits
a6fa48a
180332d
f38778a
e61a1a6
102acf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: API Documentation Artefacts Auto-Update | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||
| contents: read # For actions/checkout | ||||||||||||||||||||||||||||||||||||||||||||||||
| id-token: write # For CodeArtifact OIDC | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||||||||||||||||
| paths: | ||||||||||||||||||||||||||||||||||||||||||||||||
| - api/** | ||||||||||||||||||||||||||||||||||||||||||||||||
| types: [opened, synchronize, reopened, ready_for_review] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| defaults: | ||||||||||||||||||||||||||||||||||||||||||||||||
| run: | ||||||||||||||||||||||||||||||||||||||||||||||||
| working-directory: api | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||
| DOTENV_OVERRIDE_FILE: .env-ci | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||
| fix-docs-artefacts: | ||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: depot-ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: Fix Documentation Artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Generate GitHub App token with push access | ||||||||||||||||||||||||||||||||||||||||||||||||
| id: app-token | ||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/create-github-app-token@v1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||
| app-id: ${{ vars.FLAGSMITH_ENGINEERING_GH_APP_ID }} | ||||||||||||||||||||||||||||||||||||||||||||||||
| private-key: ${{ secrets.FLAGSMITH_ENGINEERING_GH_APP_PRIVATE_KEY }} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Cloning repo | ||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v7 | ||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||
| ref: ${{ github.event.pull_request.head.ref }} | ||||||||||||||||||||||||||||||||||||||||||||||||
| token: ${{ steps.app-token.outputs.token }} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - uses: ./.github/actions/install-uv | ||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||
| working-directory: api | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install SAML Dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||
| run: sudo apt-get install -y xmlsec1 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Generate public documentation artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||
| make install-packages opts='--extra dev' | ||||||||||||||||||||||||||||||||||||||||||||||||
| make generate-docs | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Authenticate with CodeArtifact | ||||||||||||||||||||||||||||||||||||||||||||||||
| uses: ./.github/actions/codeartifact-login | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Generate private documentation artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
| run: make generate-docs-private | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Commit and push fixes | ||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||
| git add --all | ||||||||||||||||||||||||||||||||||||||||||||||||
| if git diff --cached --quiet; then | ||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Documentation artefacts are up to date." | ||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||
| git config user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | ||||||||||||||||||||||||||||||||||||||||||||||||
| git config user.email '${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' | ||||||||||||||||||||||||||||||||||||||||||||||||
| git commit --message 'chore: Update documentation artefacts' | ||||||||||||||||||||||||||||||||||||||||||||||||
| git push || { git pull --rebase && git push; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+70
to
+71
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this violates SOC2.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean having app pushing to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean having anything pushing to main bypassing the PR approval mechanism.
Comment on lines
+61
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win Improve commit step reliability and prevent redundant CI runs.
♻️ Proposed refactor - name: Commit and push fixes
+ working-directory: ${{ github.workspace }}
run: |
git add --all
if git diff --cached --quiet; then
echo "Documentation artefacts are up to date."
exit 0
fi
git config user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config user.email '${{ steps.app-token.outputs.app-slug }}[bot]`@users.noreply.github.com`'
- git commit --message 'chore: Update documentation artefacts'
+ git commit --message 'chore: Update documentation artefacts [skip ci]'
git push || { git pull --rebase && git push; }📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.26.1)[info] 75-75: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) [info] 76-76: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) |
||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🔵 Trivial | 💤 Low value
Restrict
id-token: writepermission to the job level.Applying
id-token: writeat the workflow level grants broad access to all jobs in the workflow, which violates the principle of least privilege. While there is only one job here, it is best practice to move thepermissionsblock to the specific job that requires it.🛡️ Proposed refactor
Remove the global permissions block:
And add it to the
fix-docs-artefactsjob:🧰 Tools
🪛 zizmor (1.26.1)
[error] 5-5: overly broad permissions (excessive-permissions): id-token: write is overly broad at the workflow level
(excessive-permissions)
Source: Linters/SAST tools