-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
172 lines (156 loc) · 6.2 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
---
name: "Jellyfin manifest manager"
description: "Update a Jellyfin manifest file in a GitHub repository, and publish to gh-pages."
author: "LizardByte"
inputs:
action:
description: "The jprm action to perform. Choices are `add` or `remove`."
default: "add"
required: false
committer_email:
description: "The email address of the committer to the gh-pages branch."
required: true
committer_name:
description: "The name of the committer to the gh-pages branch."
required: true
branch:
description: "The branch where gh-pages is hosted."
default: "gh-pages"
required: false
gh_pages_url:
description: "The URL where the gh-pages branch is hosted."
default: "https://lizardbyte.github.io/jellyfin-plugin-repo"
required: false
github_token:
description: "The GitHub token used to push to the gh-pages branch."
required: true
release_tag:
description: "The tag name of the release."
default: "latest"
required: false
repository:
description: "The repository where gh-pages is hosted."
default: "LizardByte/jellyfin-plugin-repo"
required: false
plugin_url:
description: "The URL where the plugin zip file is (or will be) hosted. This will be evaluated if empty."
default: ""
required: false
zipfile:
description: "The path to the plugin zip file. This will be evaluated if empty."
default: ""
required: false
runs:
using: "composite"
steps:
- name: Setup inputs
id: inputs
shell: bash
run: |
action=${{ inputs.action }}
branch=${{ inputs.branch }}
gh_pages_url=${{ inputs.gh_pages_url }}
repository=${{ inputs.repository }}
release_tag=${{ inputs.release_tag }}
# switch to ensure the action is valid
case $action in
add)
;;
remove)
;;
*)
echo ":error: Invalid action: $action"
echo "Valid actions are 'add' or 'remove'"
exit 1
;;
esac
# the repository running this action
source_repository=${{ github.event.repository.name }}
if [[ "${{ github.event.repository }}" =~ ^LizardByte/ ]]; then
# strip `-jellyfin` from the end of the name, if in the LizardByte org
plugin_name=$(echo $source_repository | sed 's/-jellyfin$//' | tr '[:upper:]' '[:lower:]')
else
plugin_name=$(echo $source_repository | tr '[:upper:]' '[:lower:]')
fi
# release version, tag without v prefix
release_version=$(echo $release_tag | sed 's/^v//')
if [ -z "${{ inputs.zipfile }}" ]; then
# repository name in lowercase
repository_name=$(echo ${source_repository} | tr '[:upper:]' '[:lower:]')
zipfile_name=${repository_name}.zip
zipfile_path=${{ github.workspace }}/${repository_name}.zip
else
zipfile_name=$(basename ${{ inputs.zipfile }})
zipfile_path=${{ inputs.zipfile }}
fi
if [ -z "${{ inputs.plugin-url }}" ]; then
plugin_url=${{ github.event.repository.html_url }}/releases/download/${release_tag}/${zipfile_name}
else
plugin_url=${{ inputs.plugin_url }}
fi
echo "action=${action}" >> $GITHUB_OUTPUT
echo "branch=${branch}" >> $GITHUB_OUTPUT
echo "gh_pages_url=${gh_pages_url}" >> $GITHUB_OUTPUT
echo "repository=${repository}" >> $GITHUB_OUTPUT
echo "release_tag=${release_tag}" >> $GITHUB_OUTPUT
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
echo "source_repository=${source_repository}" >> $GITHUB_OUTPUT
echo "plugin_url=${plugin_url}" >> $GITHUB_OUTPUT
echo "zipfile_name=${zipfile_name}" >> $GITHUB_OUTPUT
echo "zipfile_path=${zipfile_path}" >> $GITHUB_OUTPUT
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.12"
update-environment: false
- name: Install dependencies
shell: bash
working-directory: ${{ github.action_path }}
run: |
${{ steps.setup-python.outputs.python-path }} -m pip install --upgrade pip setuptools wheel
${{ steps.setup-python.outputs.python-path }} -m pip install -r requirements.txt
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: ${{ steps.inputs.outputs.branch }}
repository: ${{ steps.inputs.outputs.repository }}
path: ${{ steps.inputs.outputs.branch }}
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
- name: JPRM repo
shell: bash
run: |
# initialize repo if it doesn't exist
${{ steps.setup-python.outputs.python-path }} \
-m jprm \
repo init \
${{ steps.inputs.outputs.branch }} || true # ignore error if already exists
# add plugin to repo
if [ "${{ steps.inputs.outputs.action }}" == "add" ]; then
${{ steps.setup-python.outputs.python-path }} \
-m jprm \
repo add \
--url ${{ steps.inputs.outputs.gh_pages_url }} \
--plugin-url ${{ steps.inputs.outputs.plugin_url }} \
${{ steps.inputs.outputs.branch }} \
${{ steps.inputs.outputs.zipfile_path }}
elif [ "${{ steps.inputs.outputs.action }}" == "remove" ]; then
${{ steps.setup-python.outputs.python-path }} \
-m jprm \
repo remove \
${{ steps.inputs.outputs.branch }} \
${{ steps.inputs.outputs.plugin_name }} \
${{ steps.inputs.outputs.release_version }}
fi
- name: Publish gh-pages
uses: actions-js/[email protected]
with:
github_token: ${{ inputs.github_token }}
author_email: ${{ inputs.committer_email }}
author_name: ${{ inputs.committer_name }}
directory: ${{ steps.inputs.outputs.branch }}
branch: ${{ steps.inputs.outputs.branch }}
force: false
message: "Bump ${{ steps.inputs.outputs.source_repository }} to ${{ steps.inputs.outputs.release_tag }}"
repository: ${{ steps.inputs.outputs.repository }}