105 lines
3.4 KiB
YAML
105 lines
3.4 KiB
YAML
name: Publish Skydust App
|
|
description: Uses generic packages to publish apps
|
|
author: Skydust
|
|
|
|
inputs:
|
|
appName:
|
|
description: "The app name to publish"
|
|
required: true
|
|
version:
|
|
description: "The version to publish (defaults to NEW_VERSION env)"
|
|
required: false
|
|
default: "${NEW_VERSION}"
|
|
publishFolder:
|
|
description: "Folder to tar, gz and publish"
|
|
required: false
|
|
default: "dist/"
|
|
ignorePatterns:
|
|
description: "A comma separated string of file patterns to ignore relative to the publish folder."
|
|
required: false
|
|
default: ""
|
|
customArchiveName:
|
|
description: "Custom archive name, useful for multi-arch"
|
|
required: false
|
|
default: "package"
|
|
token:
|
|
description: "CI Token"
|
|
required: false
|
|
default: "${{ secrets.CI_TOKEN }}"
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Packaging App
|
|
shell: bash
|
|
run: |
|
|
log_info "Packaging app into $(yellow)${{ inputs.customArchiveName }}"
|
|
cd "${{ inputs.publishFolder }}"
|
|
|
|
shopt -s dotglob
|
|
|
|
# Build tar command dynamically
|
|
tar_cmd=(
|
|
tar
|
|
-cvzf
|
|
"${{ inputs.customArchiveName }}.tar.gz"
|
|
)
|
|
|
|
if [[ -n "${{ inputs.ignorePatterns }}" ]]; then
|
|
IFS=',' read -ra exclusions <<< "${{ inputs.ignorePatterns }}"
|
|
|
|
for exclusion in "${exclusions[@]}"; do
|
|
tar_cmd+=(--exclude="${exclusion}")
|
|
log_info "Excluding pattern ${exclusion}"
|
|
done
|
|
fi
|
|
|
|
# Add all files
|
|
tar_cmd+=(*)
|
|
|
|
# Execute the tar command
|
|
"${tar_cmd[@]}"
|
|
|
|
shopt -u dotglob
|
|
|
|
mv "${{ inputs.customArchiveName }}.tar.gz" ../
|
|
- name: Publishing App
|
|
continue-on-error: true # Ensures the job shows a warning instead of failing
|
|
shell: bash
|
|
run: |
|
|
PKG_URL="${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/${{ inputs.appName }}/${{ inputs.version }}/${{ inputs.customArchiveName }}.tar.gz"
|
|
log_info "Sending package in $(yellow)${PKG_URL}"
|
|
|
|
HTTP_RESPONSE=$(curl --user "MilaBot:${{ inputs.token }}" \
|
|
--upload-file "${{ inputs.customArchiveName }}.tar.gz" \
|
|
"${PKG_URL}" \
|
|
--progress-bar \
|
|
--show-error \
|
|
--fail --silent --write-out "%{http_code}" --output /dev/null)
|
|
|
|
if [[ "$HTTP_RESPONSE" == "409" ]]; then
|
|
log_info "⚠️ Warning: File already exists (HTTP 409). Ignoring failure."
|
|
exit 1 # Step "fails", but job stays in warning state due to continue-on-error
|
|
elif [[ "$HTTP_RESPONSE" -ge 200 && "$HTTP_RESPONSE" -lt 300 ]]; then
|
|
log_info "✅ Upload successful."
|
|
exit 0
|
|
else
|
|
echo "HTTP_RESPONSE=$HTTP_RESPONSE" >> "$GITEA_ENV"
|
|
|
|
log_info "❌ Error: HTTP response $HTTP_RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
PKG_SHA="$(sha256sum "${{ inputs.customArchiveName }}.tar.gz" | cut -d' ' -f1 | tr -d '\n')"
|
|
log_info "Exporting package sha256 hash in env var $(yellow)PKG_SHA"
|
|
echo "PKG_SHA=${PKG_SHA}" >> $GITEA_ENV
|
|
|
|
log_info "Exporting package url in env var $(yellow)PKG_URL"
|
|
echo "PKG_URL=${PKG_URL}" >> $GITEA_ENV
|
|
|
|
log_info "Cleaning up"
|
|
rm -f "${{ inputs.customArchiveName }}.tar.gz"
|
|
- name: Validate job
|
|
shell: bash
|
|
run: [[ -z "$HTTP_RESPONSE" ]]; || exit 1
|