Skip to content

Run containers as non-root user with Docker --user support #252

Run containers as non-root user with Docker --user support

Run containers as non-root user with Docker --user support #252

Workflow file for this run

name: Test Links
on:
push:
branches:
- '**'
pull_request_target:
types: [opened, reopened, synchronize]
jobs:
test-links:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install nbconvert
run: |
python -m pip install --upgrade pip
pip install nbconvert
- name: Convert all notebooks to Markdown
run: |
echo "Converting all Jupyter notebooks to markdown..."
find . -name "*.ipynb" -type f | while read notebook; do
echo "Converting: $notebook"
jupyter nbconvert --to markdown "$notebook"
done
- name: Check links with Lychee
id: lychee-check
uses: lycheeverse/lychee-action@v2
with:
args: --verbose --no-progress --config brev/lychee.toml --exclude-file brev/.lycheeignore '.'
fail: true
- name: Comment on PR if check failed
if: failure() && steps.lychee-check.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
// Find PR associated with this branch
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.repo.owner}:${process.env.GITHUB_REF_NAME}`,
state: 'open'
});
if (pulls.length === 0) {
console.log('No open PR found for this branch, skipping comment.');
return;
}
const prNumber = pulls[0].number;
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const commentBody = `## ❌ Link Check Failed
**Broken links were detected in this PR.**
Please check the [workflow run logs](${runUrl}) for details on which links are broken.
### Common fixes:
1. **Typo in URL** - Check for spelling mistakes in the link
2. **Outdated link** - The page may have moved or been deleted
3. **Relative path issue** - Ensure relative links use the correct path
4. **External site down** - If the external site is temporarily down, you can add it to \`brev/.lycheeignore\`
### To test links locally:
\`\`\`bash
./brev/test-links.bash .
\`\`\`
📚 [Lychee documentation](https://github.com/lycheeverse/lychee)
`;
// Check if we already commented on this PR to avoid spam
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Link Check Failed')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
console.log(`Updated existing comment on PR #${prNumber}`);
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
console.log(`Created comment on PR #${prNumber}`);
}