-
Notifications
You must be signed in to change notification settings - Fork 10
Update GitHub Actions workflow for deployment #153
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
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,33 +1,49 @@ | ||||||||||||||||||||||
| name: Deploy internal | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| on: | ||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||
| pull_request_target: | ||||||||||||||||||||||
| branches: | ||||||||||||||||||||||
| - main | ||||||||||||||||||||||
| paths: | ||||||||||||||||||||||
| - "**/*.jmd" | ||||||||||||||||||||||
| - "**/Project.toml" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||
| generate-job-strategy-matrix: | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||
| job-strategy-matrix: ${{ steps.generate.outputs.job-strategy-matrix }} | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||
| uses: actions/checkout@v3 | ||||||||||||||||||||||
| - name: Checkout PR code | ||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| fetch-depth: 5 | ||||||||||||||||||||||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||||||||||||||||||||||
| ref: ${{ github.event.pull_request.head.sha }} | ||||||||||||||||||||||
| fetch-depth: 2 | ||||||||||||||||||||||
| persist-credentials: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: Generate MATRIX | ||||||||||||||||||||||
| id: generate | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| MATRIX=$( ( | ||||||||||||||||||||||
| echo '{ "tutorial": [' | ||||||||||||||||||||||
| git diff --name-only HEAD HEAD~1 | grep -E "(jmd|Project.toml)" | sed 's/Project.toml/index.jmd/g' | uniq | sed -r 's/(.*)/\"\1\"/g' | sed '$!s/$/,/' | ||||||||||||||||||||||
| git diff --name-only HEAD HEAD~1 \ | ||||||||||||||||||||||
| | grep -E "(jmd|Project.toml)" \ | ||||||||||||||||||||||
| | sed 's/Project.toml/index.jmd/g' \ | ||||||||||||||||||||||
| | uniq \ | ||||||||||||||||||||||
| | sed -r 's/(.*)/\"\1\"/g' \ | ||||||||||||||||||||||
| | sed '$!s/$/,/' | ||||||||||||||||||||||
| echo ']}' | ||||||||||||||||||||||
| ) | jq -c .) | ||||||||||||||||||||||
| echo $MATRIX | ||||||||||||||||||||||
| echo $MATRIX | jq . | ||||||||||||||||||||||
| echo "::set-output name=job-strategy-matrix::$MATRIX" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "$MATRIX" | ||||||||||||||||||||||
| echo "$MATRIX" | jq . | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # new-style output | ||||||||||||||||||||||
| echo "job-strategy-matrix=$MATRIX" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| build-tutorials: | ||||||||||||||||||||||
| needs: generate-job-strategy-matrix | ||||||||||||||||||||||
|
|
@@ -36,20 +52,27 @@ jobs: | |||||||||||||||||||||
| strategy: | ||||||||||||||||||||||
| matrix: ${{ fromJSON(needs.generate-job-strategy-matrix.outputs.job-strategy-matrix) }} | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||
| uses: actions/checkout@v3 | ||||||||||||||||||||||
| - name: Checkout PR code | ||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||||||||||||||||||||||
| ref: ${{ github.event.pull_request.head.sha }} | ||||||||||||||||||||||
|
Comment on lines
+55
to
+59
|
||||||||||||||||||||||
| - name: Checkout PR code | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Checkout base repository code | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.repository }} | |
| ref: ${{ github.sha }} |
Copilot
AI
Nov 28, 2025
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.
Artifact Name Conflict: The build-tutorials job runs as a matrix job (line 52-53) which can execute multiple times in parallel, but all instances upload artifacts with the same name "tutorials" (line 75). In upload-artifact@v4, artifacts with the same name will overwrite each other, causing data loss.
Recommendation: Use a unique artifact name for each matrix job, such as:
name: tutorials-${{ hashFiles(matrix.tutorial) }}or include the tutorial name in the artifact name. Then update the deploy job to download all artifacts using a pattern or merge strategy.
Copilot
AI
Nov 28, 2025
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.
Path Mismatch: The artifact is downloaded to path . (current directory) but the upload at line 76 uses path: markdown/*. When downloaded, the artifact will contain the files from the markdown/ directory directly in the download path. However, line 99 tries to copy from markdown/* which won't exist unless the artifact preserved the directory structure.
Recommendation: Either:
- Change the download path to
markdown/to preserve the expected structure, OR - Change line 99 to
cp -rf *.md JSOTutorials.jl-gh-pages/or similar pattern that matches the actual downloaded structure.
Copilot
AI
Nov 28, 2025
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.
Missing Bash Option: The script uses **/*.md glob pattern (line 108) which requires the globstar option to be enabled in bash. Without it, ** is treated as a literal string rather than matching directories recursively.
Recommendation: Add shopt -s globstar before the loop:
shopt -s globstar
for file in **/*.md; do| shopt -s globstar |
Copilot
AI
Nov 28, 2025
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.
Missing Error Handling: The loop iterates over **/*.md files without checking if any files exist. If no .md files are found, the loop will process the literal string **/*.md which could cause errors.
Recommendation: Add a check or enable nullglob:
shopt -s nullglob
for file in **/*.md; do
NAME=$(echo "$file" | cut -d/ -f 1)
TITLE=$(grep "title:" "$file" | cut -d\" -f2)
echo "- [$TITLE]($NAME/)"
done >> index.md
Copilot
AI
Nov 28, 2025
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.
Outdated Action Version: The actions/github-script@0.3.0 action is severely outdated (released in 2020). The current version is v7, which includes important security updates, bug fixes, and API improvements.
Recommendation: Update to the latest version:
uses: actions/github-script@v7| uses: actions/github-script@0.3.0 | |
| uses: actions/github-script@v7 |
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.
Critical Security Issue: Using
pull_request_targetwith checkout of untrusted PR code creates a serious security vulnerability. Thepull_request_targetevent runs with write permissions in the context of the base repository and has access to secrets, but this workflow checks out code from the fork (lines 23-24). This allows malicious actors to execute arbitrary code with elevated privileges.Recommendation: Either:
pull_requestevent instead ofpull_request_targetif you don't need write permissions during the build phase, ORpull_request_target, only checkout the PR code for isolated build steps and ensure no untrusted code runs with elevated permissions. Consider a two-stage approach where untrusted code builds in isolation, then trusted code deploys the artifacts.