Skip to content

Commit 79b4eb4

Browse files
committed
Initialising a userscripts repository using userscripts-manager
1 parent 484ba4e commit 79b4eb4

File tree

9 files changed

+200
-0
lines changed

9 files changed

+200
-0
lines changed

.github/workflows/configure.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Configure repository"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
author:
7+
description: 'Author : The name that will be used by default as the author of the scripts (typically your GitHub name/organisation)'
8+
required: true
9+
homepage:
10+
description: 'Homepage : The homepage of the that will be used by default in the scripts (typically the GitHub repository page of this repository or the Github page assiciated to this repository)'
11+
required: true
12+
support:
13+
description: 'Support URL : The website page that will be used by default in the scripts to provide support (typically the GitHub issues page of this repository)'
14+
required: true
15+
16+
jobs:
17+
configure:
18+
runs-on: "ubuntu-latest"
19+
20+
steps:
21+
- name: "Checkout"
22+
uses: actions/checkout@v3
23+
with:
24+
submodules: true
25+
26+
- name: "Create website resources"
27+
run: |
28+
bash ./manage.sh config -a "${{ inputs.author }}" -h "${{ inputs.homepage }}" -s "${{ inputs.support }}"
29+
30+
- name: "Commit"
31+
run: |
32+
if [ -z "$(git status --porcelain)" ]; then
33+
echo "No changes detected => everything is already configured"
34+
exit 0
35+
else
36+
git config user.name "GitHub Actions Bot"
37+
git config user.email "<>"
38+
git add .
39+
git commit -m "Configure repository (from GitHub Actions)"
40+
git push
41+
fi

.github/workflows/createcss.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Create a new user style (css)"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
folder:
7+
description: 'Folder : The name of the folder where your style will be placed (typically the site name where the style will render)'
8+
required: true
9+
name:
10+
description: 'Script name : A name describing what your style does (typically a string with letters and "-", so no spaces)'
11+
required: true
12+
13+
jobs:
14+
configure:
15+
runs-on: "ubuntu-latest"
16+
17+
steps:
18+
- name: "Checkout"
19+
uses: actions/checkout@v3
20+
with:
21+
submodules: true
22+
23+
- name: "Create a new style ${{ inputs.folder }}/${{ inputs.name }}"
24+
run: |
25+
bash ./manage.sh createcss "${{ inputs.folder }}" "${{ inputs.name }}"
26+
27+
- name: "Commit"
28+
run: |
29+
git config user.name "GitHub Actions Bot"
30+
git config user.email "<>"
31+
git add .
32+
git commit -m "Create a new style ${{ inputs.folder }}/${{ inputs.name }} (from GitHub Actions)"
33+
git push

.github/workflows/createjs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Create a new user script (js)"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
folder:
7+
description: 'Folder : The name of the folder where your script will be placed (typically the site name where the script will execute)'
8+
required: true
9+
name:
10+
description: 'Script name : A name describing what your script does (typically a string with letters and "-", so no spaces)'
11+
required: true
12+
13+
jobs:
14+
configure:
15+
runs-on: "ubuntu-latest"
16+
17+
steps:
18+
- name: "Checkout"
19+
uses: actions/checkout@v3
20+
with:
21+
submodules: true
22+
23+
- name: "Create a new script ${{ inputs.folder }}/${{ inputs.name }}"
24+
run: |
25+
bash ./manage.sh createjs "${{ inputs.folder }}" "${{ inputs.name }}"
26+
27+
- name: "Commit"
28+
run: |
29+
git config user.name "GitHub Actions Bot"
30+
git config user.email "<>"
31+
git add .
32+
git commit -m "Create a new script ${{ inputs.folder }}/${{ inputs.name }} (from GitHub Actions)"
33+
git push

.github/workflows/publish.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Publish user scripts and styles to GitHub Pages"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- name: "Checkout"
15+
uses: actions/checkout@v3
16+
with:
17+
submodules: true
18+
19+
- name: "Set env vars"
20+
run: |
21+
export_ga() {
22+
for _name in "${@}"
23+
do
24+
local _key="${_name%%=*}"
25+
local _value="${_name#*=}"
26+
[ "${_key}" == "${_name}" ] && _value="${!_name}"
27+
export $_key="${_value}"
28+
echo "${_key}=${_value}" >> "${GITHUB_ENV}"
29+
done
30+
}
31+
32+
export_ga GITHUB_SHA_SHORT="$(git rev-parse --short HEAD)"
33+
34+
- name: "Create website resources"
35+
run: |
36+
bash ./manage.sh publish -v "${{ env.GITHUB_SHA_SHORT }}"
37+
38+
- name: "Deploy to GitHub Pages"
39+
if: "success()"
40+
uses: "crazy-max/[email protected]"
41+
with:
42+
target_branch: "gh-pages"
43+
build_dir: "dist"
44+
commit_message: "Synchronize website to ${{ env.GITHUB_SHA_SHORT }}"
45+
env:
46+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/update.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Update the tool to the latest version"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
configure:
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- name: "Checkout"
15+
uses: actions/checkout@v3
16+
with:
17+
submodules: true
18+
token: ${{ secrets.PAT_WORKFLOW }}
19+
20+
- name: "git config"
21+
run: |
22+
git config --global user.name "GitHub Actions Bot"
23+
git config --global user.email "<>"
24+
git config --global pull.rebase true
25+
26+
- name: "Update the tool"
27+
run: |
28+
bash ./manage.sh update
29+
30+
- name: "Commit"
31+
run: |
32+
if [ -z "$(git status --porcelain)" ]; then
33+
echo "No changes detected => everything is up-to-date"
34+
exit 0
35+
else
36+
git add .
37+
git commit -m "Update the tool to the latest version (from GitHub Actions)"
38+
git push
39+
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
tmp/
3+
.vscode

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "userscripts-manager"]
2+
path = userscripts-manager
3+
url = https://github.com/userscripts-manager/userscripts-manager

manage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
userscripts-manager/manage.sh

userscripts-manager

Submodule userscripts-manager added at 9112913

0 commit comments

Comments
 (0)