-
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
Changes from 10 commits
95dee33
a2faec7
cdd3d6c
d332be8
96b256c
e821a33
f7622ba
893812e
0e80d77
e881b20
292a1f9
3e51eb2
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#/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_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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have ssh keys setup with a different variable (I believe), so this PR will only use I think we should use the production keys for production and preview keys for previews, what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It seems there are no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please, could you possibly share if it would be possible to rename it and setup its There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. It's a little weird that it would quit to push to production if GIT_PR_PREVIEW_PRIVATE_SSH_KEY is empty. But I guess that's fine. Would it make sense to put this into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, got it.
Shaikh-Ubaid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
git push ${deploy_repo_push} gh-pages:gh-pages |
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)