@@ -31,48 +31,74 @@ inputs:
3131runs :
3232 using : composite
3333 steps :
34+ - name : Validate Branch/Tag Name
35+ shell : bash
36+ run : |
37+ REF_NAME="${{ github.ref_name }}"
38+
39+ # Check if ref name contains only allowed characters (letters, digits, dash, underscore, dot)
40+ if [[ ! "$REF_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
41+ echo "Branch/tag name '$REF_NAME' contains illegal characters. Only letters, digits, dash (-), underscore (_), and dot (.) are allowed."
42+ echo "Skipping action execution due to invalid ref name."
43+ echo "JDEPLOY_SKIP_EXECUTION=true" >> $GITHUB_ENV
44+ exit 0
45+ fi
46+
47+ # Check if ref name length exceeds 16 characters
48+ if [[ ${#REF_NAME} -gt 16 ]]; then
49+ echo "Branch/tag name '$REF_NAME' is too long (${#REF_NAME} characters). Maximum allowed length is 16 characters."
50+ echo "Skipping action execution due to ref name length limit."
51+ echo "JDEPLOY_SKIP_EXECUTION=true" >> $GITHUB_ENV
52+ exit 0
53+ fi
54+
55+ echo "Branch/tag name '$REF_NAME' is valid."
56+ echo "JDEPLOY_SKIP_EXECUTION=false" >> $GITHUB_ENV
3457 - name : Check Deploy Target
35- if : ${{ inputs.deploy_target != 'github' && inputs.deploy_target != 'npm' }}
58+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target != 'github' && inputs.deploy_target != 'npm' }}
3659 shell : bash
3760 run : |
3861 echo "Unsupported jdeploy deploy_target: ${{ inputs.deploy_target }}"
3962 exit 1
4063 - name : Check Github Deployment Inputs
41- if : ${{ inputs.deploy_target == 'github' && inputs.github_token == '' }}
64+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && inputs.github_token == '' }}
4265 shell : bash
4366 run : |
4467 echo "jdeploy action missing github_token parameter"
4568 exit 1
4669 - name : Check npm Deployment Inputs
47- if : ${{ inputs.deploy_target == 'npm' && inputs.npm_token == '' }}
70+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'npm' && inputs.npm_token == '' }}
4871 shell : bash
4972 run : |
5073 echo "jdeploy action missing npm_token parameter"
5174 exit 1
5275 - name : Set up Git Config
76+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' }}
5377 shell : bash
5478 run : |
5579 git config user.name "GitHub Actions Bot"
5680 git config user.email "<>"
5781 - name : Set up Node
82+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' }}
5883 uses : actions/setup-node@v2
5984 with :
6085 node-version : ' 16.x'
6186 registry-url : ' https://registry.npmjs.org'
6287
6388 - name : Setup jDeploy Registry
89+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' }}
6490 shell : bash
6591 run : |
6692 echo "JDEPLOY_REGISTRY_URL=${{ inputs.jdeploy_registry_url }}" >> $GITHUB_ENV
6793
6894 - name : Save Original JAVA_HOME
69- if : env.JAVA_HOME
95+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && env. JAVA_HOME }}
7096 shell : bash
7197 run : |
7298 echo "ORIGINAL_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
7399
74100 - name : Set up Isolated Java for jDeploy (only for git:// version)
75- if : ${{ startsWith(inputs.jdeploy_version, 'git://') }}
101+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
76102 uses : actions/setup-java@v3
77103 with :
78104 java-version : ' 11'
@@ -81,29 +107,29 @@ runs:
81107 id : setup-java-jdeploy
82108
83109 - name : Configure Java for jDeploy Only
84- if : ${{ startsWith(inputs.jdeploy_version, 'git://') }}
110+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
85111 shell : bash
86112 run : |
87113 echo "JAVA_HOME_JDEPLOY=${{ steps.setup-java-jdeploy.outputs.path }}" >> $GITHUB_ENV
88114 echo "Using isolated JAVA_HOME for jDeploy: $JAVA_HOME_JDEPLOY"
89115
90116 - name : Restore Original JAVA_HOME
91- if : ${{ startsWith(inputs.jdeploy_version, 'git://') && env.ORIGINAL_JAVA_HOME }}
117+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') && env.ORIGINAL_JAVA_HOME }}
92118 shell : bash
93119 run : |
94120 echo "Restoring original JAVA_HOME"
95121 echo "JAVA_HOME=${ORIGINAL_JAVA_HOME}" >> $GITHUB_ENV
96122
97123 - name : Set jDeploy Ref
98- if : ${{ startsWith(inputs.jdeploy_version, 'git://') }}
124+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
99125 shell : bash
100126 run : |
101127 jdeploy_version="${{ inputs.jdeploy_version }}"
102128 JDEPLOY_REF="${jdeploy_version#git://}"
103129 echo "JDEPLOY_REF=$JDEPLOY_REF" >> $GITHUB_ENV
104130
105131 - name : Checkout jDeploy Source
106- if : ${{ startsWith(inputs.jdeploy_version, 'git://') }}
132+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
107133 uses : actions/checkout@v3
108134 with :
109135 repository : ' shannah/jdeploy'
@@ -112,7 +138,7 @@ runs:
112138
113139 - name : Install jDeploy from Source
114140 id : jdeploy_install_source
115- if : ${{ startsWith(inputs.jdeploy_version, 'git://') }}
141+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
116142 shell : bash
117143 run : |
118144 export JAVA_HOME="$JAVA_HOME_JDEPLOY"
@@ -130,15 +156,15 @@ runs:
130156
131157 - name : Install jDeploy from NPM
132158 id : jdeploy_install_standard
133- if : ${{ !startsWith(inputs.jdeploy_version, 'git://') }}
159+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && !startsWith(inputs.jdeploy_version, 'git://') }}
134160 shell : bash
135161 run : |
136162 echo "jdeploy_exec=npx jdeploy@${JDEPLOY_VERSION}" >> $GITHUB_ENV
137163 env :
138164 JDEPLOY_VERSION : ${{ inputs.jdeploy_version }}
139165
140166 - name : Set jdeploy.jdeployVersion for Branch
141- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
167+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
142168 shell : bash
143169 run : |
144170 if [[ "${{ startsWith(inputs.jdeploy_version, 'git://') }}" == "true" ]]; then
@@ -153,8 +179,8 @@ runs:
153179 GH_TOKEN : ${{ github.actor }}:${{ inputs.github_token }}
154180
155181 - name : Sanitize version name
182+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && github.ref_type == 'tag' }}
156183 shell : bash
157- if : ${{ github.ref_type == 'tag' }}
158184 run : |
159185 TAG_VERSION=${{ github.ref_name }}
160186 if [[ $TAG_VERSION} = v* ]]; then
@@ -163,7 +189,7 @@ runs:
163189 echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_ENV
164190 fi
165191 - name : Prepare Installer Bundles for Branch
166- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
192+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
167193 shell : bash
168194 run : |
169195 npm pkg set version="0.0.0-${{ github.ref_name }}"
@@ -178,7 +204,7 @@ runs:
178204 GH_TOKEN : ${{ github.actor }}:${{ inputs.github_token }}
179205
180206 - name : Prepare Installer Bundles for Tag
181- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'tag' }}
207+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' }}
182208 shell : bash
183209 run : |
184210 npm pkg set version="$TAG_VERSION"
@@ -195,15 +221,15 @@ runs:
195221
196222 - name : Publish package-info.json to GitHub
197223 uses : softprops/action-gh-release@v2
198- if : ${{ inputs.deploy_target == 'github' && inputs.target_repository == github.repository }}
224+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && inputs.target_repository == github.repository }}
199225 with :
200226 token : ${{ inputs.github_token }}
201227 tag_name : " jdeploy"
202228 prerelease : true
203229 files : ./jdeploy/github-release-files/package-info.json
204230
205231 - name : Publish package-info.json to Github
206- if : ${{ inputs.deploy_target == 'github' && inputs.target_repository != github.repository }}
232+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && inputs.target_repository != github.repository }}
207233 shell : bash
208234 run : |
209235 gh release delete -R '${{ inputs.target_repository }}' jdeploy || true
@@ -213,7 +239,7 @@ runs:
213239
214240 - name : Upload files to GitHub Snapshot Release for Branch
215241 uses : softprops/action-gh-release@v2
216- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
242+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
217243 with :
218244 tag_name : " ${{ github.ref_name }}"
219245 token : " ${{ inputs.github_token }}"
@@ -222,7 +248,7 @@ runs:
222248 ./jdeploy/github-release-files/*
223249
224250 - name : Upload files to Github Snapshot Release for Branch
225- if : ${{ inputs.deploy_target == 'github' && inputs.target_repository != github.repository }}
251+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && inputs.target_repository != github.repository }}
226252 shell : bash
227253 run : |
228254 gh release delete -R '${{ inputs.target_repository }}' '${{ github.ref_name }}' || true
@@ -231,7 +257,7 @@ runs:
231257 GH_TOKEN : ${{ inputs.github_token }}
232258
233259 - name : Upload Files to Github Release for Tag
234- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository == github.repository }}
260+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository == github.repository }}
235261 uses : xresloader/upload-to-github-release@v1.6.0
236262 env :
237263 GITHUB_TOKEN : ${{ inputs.github_token }}
@@ -241,7 +267,7 @@ runs:
241267 overwrite : true
242268
243269 - name : Update release body (for branch release)
244- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'branch' && inputs.target_repository == github.repository }}
270+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' && inputs.target_repository == github.repository }}
245271 shell : bash
246272 env :
247273 GITHUB_TOKEN : ${{ inputs.github_token }}
@@ -268,7 +294,7 @@ runs:
268294 -d "$BODY_JSON"
269295
270296 - name : Update release body (for tag release)
271- if : ${{ inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository == github.repository }}
297+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository == github.repository }}
272298 shell : bash
273299 env :
274300 GITHUB_TOKEN : ${{ inputs.github_token }}
@@ -298,7 +324,7 @@ runs:
298324 -d "$BODY_JSON"
299325
300326 - name : Publish to npm
301- if : ${{ inputs.deploy_target == 'npm' && github.ref_type == 'tag' }}
327+ if : ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'npm' && github.ref_type == 'tag' }}
302328 shell : bash
303329 env :
304330 NODE_AUTH_TOKEN : ${{ inputs.npm_token }}
0 commit comments