-
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.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
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,42 @@ | ||
name: Minify JavaScript | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'script.user.js' | ||
|
||
jobs: | ||
minify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
- name: Install UglifyJS | ||
run: npm install uglify-js -g | ||
|
||
- name: Minify JavaScript | ||
run: | | ||
uglifyjs script.user.js -o script.min.js -c -m | ||
- name: Create/Update minified branch | ||
run: | | ||
git config --global user.name 'GitHub Action' | ||
git config --global user.email 'action@github.com' | ||
git checkout --orphan minified | ||
git rm -rf . | ||
mv script.min.js script.user.js | ||
git add script.user.js | ||
git commit -m "Update minified script" | ||
git push origin minified --force | ||
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