Skip to content

fixed preview workflow and added current version in navbar! #488

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

Merged
merged 39 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7020849
update preview workflow
shravanngoswamii Jun 29, 2024
28ddea1
testing preview workflow
shravanngoswamii Jun 29, 2024
0796c2b
testing preview workflow
shravanngoswamii Jun 29, 2024
32afd7b
testing preview workflow
shravanngoswamii Jun 29, 2024
9420566
testing preview workflow
shravanngoswamii Jun 29, 2024
2774757
tests
shravanngoswamii Jun 29, 2024
b521bcd
test2
shravanngoswamii Jun 29, 2024
81233d3
test2
shravanngoswamii Jun 29, 2024
b3ab87a
test2
shravanngoswamii Jun 29, 2024
f6d21cc
test2
shravanngoswamii Jun 29, 2024
970c000
thollander comment workflow
shravanngoswamii Jun 29, 2024
e222b97
thollander comment workflow
shravanngoswamii Jun 29, 2024
40c2ffc
thollander comment workflow
shravanngoswamii Jun 29, 2024
dee918a
thollander comment workflow
shravanngoswamii Jun 29, 2024
45d8b1c
vcheck workflow test for forks
shravanngoswamii Jun 29, 2024
2429d3d
vcheck skip
shravanngoswamii Jun 29, 2024
c0f68e1
added vdropdown with current version in navbar
shravanngoswamii Jul 2, 2024
ab64b34
hotfix in _quarto.yml
shravanngoswamii Jul 2, 2024
21f8c03
ajusted vdropdown a bit
shravanngoswamii Jul 2, 2024
f9ffdc4
updated comments
shravanngoswamii Jul 2, 2024
ed0df9c
removed version and changelog from sidebar
shravanngoswamii Jul 2, 2024
0ce8a6c
testing new workflow
shravanngoswamii Jul 4, 2024
d5c417a
updated vcheck
shravanngoswamii Jul 4, 2024
cdc46fe
updated version in _quarto.yml
shravanngoswamii Jul 4, 2024
e0c8e1b
updated version in _quarto.yml
shravanngoswamii Jul 4, 2024
b3dd56e
Changed sed to awk
shravanngoswamii Jul 4, 2024
a97f899
updated vcheck
shravanngoswamii Jul 4, 2024
1e1bdb3
updated publish.yml
shravanngoswamii Jul 4, 2024
b465a42
.
shravanngoswamii Jul 4, 2024
7be6e70
.
shravanngoswamii Jul 4, 2024
467a8cf
updated vcheck
shravanngoswamii Jul 6, 2024
32ac5b9
updated vcheck
shravanngoswamii Jul 6, 2024
32c15b8
another suggestion workflow
shravanngoswamii Jul 6, 2024
d23dcf9
updated suggestion workflow
shravanngoswamii Jul 6, 2024
adb52c0
manual approach
shravanngoswamii Jul 6, 2024
c5f211f
json parsing fixed
shravanngoswamii Jul 6, 2024
af7b8a5
continue on error previous worklow
shravanngoswamii Jul 6, 2024
ee633d8
finally its done😊
shravanngoswamii Jul 6, 2024
bff58da
Update .github/workflows/vcheck.yml
shravanngoswamii Jul 6, 2024
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
92 changes: 26 additions & 66 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand Down Expand Up @@ -48,91 +48,51 @@ jobs:
_freeze/
key: ${{ runner.os }}-primes-${{ github.run_id }}

- name: Checkout gh-pages branch
uses: actions/checkout@v3
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
ref: gh-pages
path: gh-pages
branch: gh-pages
folder: _site
target-folder: pr-previews/${{ github.event.pull_request.number }}
clean: false
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy Preview to GitHub Pages
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
mkdir -p gh-pages/${PREVIEW_DIR}
cp -r _site/* gh-pages/${PREVIEW_DIR}
cd gh-pages
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Deploy preview for PR ${PR_NUMBER}"
git push
comment-preview-url:
needs: build-and-preview
if: needs.build-and-preview.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Comment Preview URL
uses: thollander/actions-comment-pull-request@v2
with:
message: |
<!-- preview-url-comment -->
Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }}
Please avoid using the search feature and navigation bar in PR previews!
comment_tag: preview-url-comment
env:
GH_PAT: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

delete-preview-directory:
if: github.event.action == 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove PR Preview Directory
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git pull origin gh-pages
rm -rf ${PREVIEW_DIR}
git add .
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

comment-preview-url:
needs: build-and-preview
if: needs.build-and-preview.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Comment Preview URL
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const repoName = context.repo.repo;
const previewUrl = `https://turinglang.org/${repoName}/pr-previews/${prNumber}`;
const commentBody = `Preview the changes: ${previewUrl}, Please avoid using the search feature and navigation bar in PR previews!`;
const botUsername = 'github-actions[bot]';

// Check for existing comments by the bot
const existingComments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});

const botComment = existingComments.data.find(
(comment) => comment.user.login === botUsername
);

if (botComment) {
// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody,
});
} else {
// Create a new comment
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody,
});
}

12 changes: 11 additions & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ project:
pre-render:
- sh assets/scripts/changelog.sh
- sh assets/scripts/versions.sh
- sh assets/scripts/vdropdown.sh

# These cannot be used as variables. They are reserved for the project configuration.
website:
Expand All @@ -33,6 +34,15 @@ website:
text: News
- href: https://turinglang.org/team/
text: Team
right:
# The current version will be inserted here by the script
- text: "v0.33.0"
# The current version ends here
menu:
- text: Changelog
href: https://turinglang.org/docs/changelog.html
- text: All Versions
href: https://turinglang.org/docs/versions.html
tools:
- icon: twitter
href: https://x.com/TuringLang
Expand Down Expand Up @@ -132,7 +142,7 @@ website:
aria-label: Turing GitHub

back-to-top-navigation: true
repo-url: https://github.com/TuringLang/TuringTutorials
repo-url: https://github.com/TuringLang/docs
repo-actions: [edit, issue]
repo-branch: master
repo-link-target: _blank
Expand Down
27 changes: 27 additions & 0 deletions assets/scripts/vdropdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Read the current version from the VERSION file
CURRENT_VERSION=$(cat VERSION)

# Define the current version to be inserted
VERSIONS_SECTION=$(cat << EOF
# The current version will be inserted here by the script
- text: "$CURRENT_VERSION"
# The current version ends here
EOF
)

# Use awk to replace the existing versions section between the comments
awk -v versions="$VERSIONS_SECTION" '
BEGIN { in_versions = 0 }
/# The current version will be inserted here by the script/ {
print versions
in_versions = 1
next
}
/# The current version ends here/ {
in_versions = 0
next
}
!in_versions { print $0 }
' _quarto.yml > _quarto.yml.tmp && mv _quarto.yml.tmp _quarto.yml
8 changes: 8 additions & 0 deletions theming/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@
.nav-footer-center {
display: flex;
justify-content: center;
}

.dropdown-menu {
text-align: center;
min-width: 100px !important;
border-radius: 5px;
max-height: 250px;
overflow: scroll;
}
Loading