-
Notifications
You must be signed in to change notification settings - Fork 48
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
Automatically update and publish to GitHub pages using GitHub actions #18
Conversation
Change uglify-es to uglify-js; When building, download uglify-js from GitHub releases instead of git; When publishing, use CDN instead of local files for uglify-js;
@BlueHtml, thank you, I really appreciate the PR! |
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.
Thanks for helping to modernize this repo using GH actions. Just a couple of minor suggestions for how to avoid unnecessary dependencies.
.github/workflows/main.yml
Outdated
run: bash build/update.sh | ||
# Deploy the site | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v4 |
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.
What advantages are there to using this custom action instead of Github's "standard" actions? I'm not familiar with either, so I was just looking at Github's suggested workflows, in this case the "static HTML" one.
# Github's suggestion: "Static HTML"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
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.
According to the GitHub Pages documentation:
Most external CI workflows "deploy" to GitHub Pages by committing the build output to the gh-pages branch of the repository, and typically include a .nojekyll file.
Use the actions/upload-pages-artifact action to upload the static files as an artifact.
use the actions/deploy-pages action to deploy the artifact.
peaceiris/actions-gh-pages
: This action creates a gh-pages branch, and we need to configure GitHub Pages to use thisgh-pages
branch.- Settings -> Pages -> Build and deployment -> Source -> Select
Deploy from a branch
-> Selectgh-pages
branch
- Settings -> Pages -> Build and deployment -> Source -> Select
Github's "standard" actions
(actions/upload-pages-artifact + actions/deploy-pages
): This action will create an artifact, and then we need to configure GitHub Pages to useGitHub Actions
.- Settings -> Pages -> Build and deployment -> Source -> Select
GitHub Actions
- Settings -> Pages -> Build and deployment -> Source -> Select
I think using the gh-pages branch is better because switching branches allows you to see the generated static files.
But the artifact needs to be downloaded to view the file, and the artifact will expire, with a default of 90 days(By default, GitHub stores build logs and artifacts for 90 days, and this retention period can be customized.
)
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.
Makes sense, thanks for explaining!
build/update.sh
Outdated
CDN="//registry.npmmirror.com/uglify-js/$VERSION/files" | ||
CDN="${CDN//\//\\\/}" | ||
sed -i 's/\(<script src="\)uglify/\1'"$CDN"'/gI' index.html | ||
|
||
rm -rf uglify |
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 see the point of using a CDN here. We should be able to just copy the uglify
dir into public
, right?
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.
Certainly. I will remove CDN and use local files ( I am in China, CDN speed will be faster )
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.
Thanks. If we want to speed things up, it might help to concat the relevant JS files, but that could be done in a follow-up PR if you'd like.
Hello, I have upgraded uglify-es to uglify-js, and added the feature of using GitHub actions to automatically update and publish to GitHub pages.
Here are the specific changes:
registry.npmmirror.com
) instead of local files for uglify-js;Update steps:
update
to build and publish to the gh-pages branch;