-
Notifications
You must be signed in to change notification settings - Fork 8
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
CI: Support PR Preview #38
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
95dee33
CI: Add pull request preview workflow
Shaikh-Ubaid a2faec7
CI: Add steps from pr_preview.yml to deploy.yml
Shaikh-Ubaid cdd3d6c
CI: Remove pr_preview.yml workflow
Shaikh-Ubaid d332be8
CI: Run deploy workflow on pull requests
Shaikh-Ubaid 96b256c
CI: Push to respective repos depending on branch
Shaikh-Ubaid e821a33
CI: Comment only on pull request and when running at origin
Shaikh-Ubaid f7622ba
CI: Update the repository links
Shaikh-Ubaid 893812e
CI: Update preview link
Shaikh-Ubaid 0e80d77
Fix path
Shaikh-Ubaid e881b20
Revert "Fix path"
Shaikh-Ubaid 292a1f9
CI: Fix: pushing to production
Shaikh-Ubaid 3e51eb2
Do not use ssh keys when in main branch
Shaikh-Ubaid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,50 @@ | ||
#/usr/bin/bash | ||
|
||
set -ex | ||
|
||
git_ref=${GITHUB_REF} | ||
|
||
if [[ ${git_ref} == "refs/heads/main" ]]; then | ||
# Production version - pipeline triggered from main branch | ||
deploy_repo_pull="https://github.com/lfortran/lcompilers_frontend.git" | ||
deploy_repo_push="[email protected]:lfortran/lcompilers_frontend.git" | ||
else | ||
# Test version - pipeline triggered from pull request | ||
deploy_repo_pull="https://github.com/lfortran/pull_request_preview.git" | ||
deploy_repo_push="[email protected]:lfortran/pull_request_preview.git" | ||
fi | ||
|
||
|
||
mkdir ~/.ssh | ||
chmod 700 ~/.ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
eval "$(ssh-agent -s)" | ||
|
||
D=`pwd` | ||
|
||
mkdir $HOME/repos | ||
cd $HOME/repos | ||
|
||
git clone ${deploy_repo_pull} pr_preview | ||
cd pr_preview | ||
git fetch origin | ||
git checkout gh-pages | ||
rm -rf * | ||
mv $D/deploy/* . | ||
|
||
git config user.email "noreply@deploy" | ||
git config user.name "Deploy" | ||
|
||
git add . | ||
COMMIT_MESSAGE="Deploying on $(date "+%Y-%m-%d %H:%M:%S")" | ||
git commit -m "${COMMIT_MESSAGE}" | ||
|
||
if [[ ${git_ref} != "refs/heads/main" ]]; then | ||
if [[ "${GIT_PR_PREVIEW_PRIVATE_SSH_KEY}" == "" ]]; then | ||
echo "Note: GIT_PR_PREVIEW_PRIVATE_SSH_KEY is empty, skipping..." | ||
exit 0 | ||
fi | ||
ssh-add <(echo "$GIT_PR_PREVIEW_PRIVATE_SSH_KEY" | base64 -d) | ||
fi | ||
|
||
git push ${deploy_repo_push} gh-pages:gh-pages |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't know how subdomains work --- we can also just use regular github pages, to make it clear it is just a PR preview.
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.
It seems when we use the regular github pages, the site would be available at https://lfortran.github.io/pull_request_preview and thus adding the path
/pull_request_preview
to the url. Supporting the path might be challenging as I shared here #38 (comment)