forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Add
/make-notebooks
command (JuliaLang#228)
- Loading branch information
1 parent
b644c47
commit fd829be
Showing
4 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 'Generate Jupyter notebooks' | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
format: | ||
name: 'Generate Jupyter notebooks' | ||
runs-on: ubuntu-latest | ||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/make-notebooks') | ||
steps: | ||
- name: 'Checkout code' | ||
run: | | ||
PR_DATA="/tmp/pr.json" | ||
jq -r ".issue.pull_request.url" "$GITHUB_EVENT_PATH" | \ | ||
xargs curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -o "$PR_DATA" --url | ||
HEAD_REF=$(jq -r ".head.ref" "$PR_DATA") | ||
HEAD_REPO=$(jq -r '.head.repo.clone_url | sub("https://"; "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@")' "$PR_DATA") | ||
git clone $HEAD_REPO . | ||
git checkout -b "$HEAD_REF" "origin/$HEAD_REF" | ||
- name: 'Generate notebooks' | ||
run: julia bin/generate-notebooks.jl | ||
|
||
- name: 'Commit generated notebooks' | ||
run: | | ||
# Check if there is nothing to commit (i.e. no formatting changes made) | ||
if [ -z "$(git status --porcelain)" ]; then | ||
echo "Notebooks have already been generated." | ||
exit 0 | ||
fi | ||
# Setup the git user (required to commit anything) | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
# Commit the changes | ||
git add . | ||
git commit -m "Generate notebooks" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.