feat: prepare the url in the prepare step
This commit is contained in:
parent
e06390119f
commit
26deb8e8c8
1 changed files with 53 additions and 37 deletions
90
action.yml
90
action.yml
|
@ -48,58 +48,74 @@ runs:
|
||||||
run: |
|
run: |
|
||||||
echo '::group::Prepared Data'
|
echo '::group::Prepared Data'
|
||||||
|
|
||||||
#
|
|
||||||
# Forge URL
|
|
||||||
#
|
|
||||||
echo "gitea.server_url = ${{ gitea.server_url }}"
|
|
||||||
echo "inputs.forge_url = ${{ inputs.forge_url }}"
|
|
||||||
FORGE_URL='${{ gitea.server_url }}'
|
|
||||||
if [ -n '${{ inputs.forge_url }}' ]; then
|
|
||||||
FORGE_URL='${{ inputs.forge_url }}'
|
|
||||||
fi
|
|
||||||
echo "Setting forge URL to ${FORGE_URL}"
|
|
||||||
echo "::set-output name=forge_url::${FORGE_URL}"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Package
|
# Package
|
||||||
#
|
#
|
||||||
files=(*.pkg.tar.zst)
|
echo '::group::Package'
|
||||||
echo "Files discovered: ${files}"
|
FILES=(*.pkg.tar.zst)
|
||||||
echo "inputs.package = ${{ inputs.package }}"
|
echo "Files discovered: ${FILES}"
|
||||||
|
echo 'inputs.package = ${{ inputs.package }}'
|
||||||
if [ -n '${{ inputs.package }}' ]; then
|
if [ -n '${{ inputs.package }}' ]; then
|
||||||
if [[ "${#files[@]}" == 1 ]]; then
|
if [[ "${#FILES[@]}" == 1 ]]; then
|
||||||
|
echo "Setting package to ${FILES[0]}"
|
||||||
echo "Setting package to ${files[0]}"
|
echo "::set-output name=package::${FILES[0]}"
|
||||||
echo "::set-output name=package::${files[0]}"
|
|
||||||
else
|
else
|
||||||
echo "::error title=package::No package was provided and the number of packages in the output is greater than 1."
|
echo '::error title=package::No package was provided and the number of packages in the output is greater than 1.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
#
|
|
||||||
# Package Owner
|
|
||||||
#
|
|
||||||
echo "gitea.repository_owner = ${{ gitea.repository_owner }}"
|
|
||||||
echo "inputs.package_owner = ${{ inputs.package_owner }}"
|
|
||||||
PACKAGE_OWNER='${{ gitea.repository_owner }}'
|
|
||||||
if [ -n '${{ inputs.package_owner }}' ]; then
|
|
||||||
PACKAGE_OWNER='${{ inputs.package_owner }}'
|
|
||||||
fi
|
|
||||||
echo "Setting forge URL to ${PACKAGE_OWNER}"
|
|
||||||
echo "::set-output name=package_owner::${PACKAGE_OWNER}"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Username
|
# Username
|
||||||
#
|
#
|
||||||
echo "gitea.actor = ${{ gitea.actor }}"
|
echo '::group::Username'
|
||||||
echo "inputs.username = ${{ inputs.username }}"
|
echo 'gitea.actor = ${{ gitea.actor }}'
|
||||||
|
echo 'inputs.username = ${{ inputs.username }}'
|
||||||
USERNAME='${{ gitea.actor }}'
|
USERNAME='${{ gitea.actor }}'
|
||||||
if [ -n '${{ inputs.username }}' ]; then
|
if [ -n '${{ inputs.username }}' ]; then
|
||||||
USERNAME='${{ inputs.username }}'
|
USERNAME='${{ inputs.username }}'
|
||||||
fi
|
fi
|
||||||
echo "Setting username to ${USERNAME}"
|
echo "Setting username to ${USERNAME}"
|
||||||
echo "::set-output name=username::${USERNAME}"
|
echo "::set-output name=username::${USERNAME}"
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Package Owner (local)
|
||||||
|
#
|
||||||
|
echo '::group::Package Owner'
|
||||||
|
echo 'gitea.repository_owner = ${{ gitea.repository_owner }}'
|
||||||
|
echo 'inputs.package_owner = ${{ inputs.package_owner }}'
|
||||||
|
PACKAGE_OWNER='${{ gitea.repository_owner }}'
|
||||||
|
if [ -n '${{ inputs.package_owner }}' ]; then
|
||||||
|
PACKAGE_OWNER='${{ inputs.package_owner }}'
|
||||||
|
fi
|
||||||
|
echo "Setting forge URL to ${PACKAGE_OWNER} (local)"
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Forge URL (local
|
||||||
|
#
|
||||||
|
echo '::group::Forgejo URL'
|
||||||
|
echo 'gitea.server_url = ${{ gitea.server_url }}'
|
||||||
|
echo 'inputs.forge_url = ${{ inputs.forge_url }}'
|
||||||
|
FORGE_URL='${{ gitea.server_url }}'
|
||||||
|
if [ -n '${{ inputs.forge_url }}' ]; then
|
||||||
|
FORGE_URL='${{ inputs.forge_url }}'
|
||||||
|
fi
|
||||||
|
echo "Setting forge URL to ${FORGE_URL} (local)"
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Package URL
|
||||||
|
#
|
||||||
|
echo '::group::Package URL'
|
||||||
|
PACKAGE_URL="${FORGE_URL}/api/packages/${PACKAGE_OWNER}/arch/${{ inputs.package_repository_name }}"
|
||||||
|
echo "Setting package URL to: ${PACKAGE_URL}"
|
||||||
|
echo "::set-output name=package_url::${PACKAGE_URL}"
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
echo '::endgroup::'
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
@ -110,18 +126,15 @@ runs:
|
||||||
curl --version
|
curl --version
|
||||||
echo '::endgroup::'
|
echo '::endgroup::'
|
||||||
|
|
||||||
PACKAGE_URL='${{ steps.prepared.outputs.forge_url }}/api/packages/${{ steps.prepared.outputs.package_owner }}/arch/${{ inputs.package_repository_name }}'
|
|
||||||
echo "PACKAGE_URL: ${PACKAGE_URL}"
|
|
||||||
|
|
||||||
echo '::group::Request'
|
echo '::group::Request'
|
||||||
RESPONSE=$(
|
RESPONSE=$(
|
||||||
curl -X PUT "${PACKAGE_URL}" \
|
curl -X PUT '${{ steps.prepared.outputs.package_url }}' \
|
||||||
--silent \
|
--silent \
|
||||||
--verbose \
|
--verbose \
|
||||||
--write-out '\n%{http_code}' \
|
--write-out '\n%{http_code}' \
|
||||||
--user '${{ steps.prepared.outputs.username }}:${{ inputs.PERSONAL_ACCESS_TOKEN }}' \
|
--user '${{ steps.prepared.outputs.username }}:${{ inputs.PERSONAL_ACCESS_TOKEN }}' \
|
||||||
--header 'Content-Type: application/octet-stream' \
|
--header 'Content-Type: application/octet-stream' \
|
||||||
--data-binary "@${{ steps.prepared.outputs.package }}"
|
--data-binary '@${{ steps.prepared.outputs.package }}'
|
||||||
)
|
)
|
||||||
echo '::endgroup::'
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
@ -136,6 +149,9 @@ runs:
|
||||||
echo "${HTTP_CODE}"
|
echo "${HTTP_CODE}"
|
||||||
echo '::endgroup::'
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
#
|
||||||
|
# Handle Result
|
||||||
|
#
|
||||||
if ((HTTP_CODE >= 200 && HTTP_CODE <= 399)); then
|
if ((HTTP_CODE >= 200 && HTTP_CODE <= 399)); then
|
||||||
# Success
|
# Success
|
||||||
echo 'The package ${{ steps.prepared.outputs.package }} was successfully pushed to the package registry'
|
echo 'The package ${{ steps.prepared.outputs.package }} was successfully pushed to the package registry'
|
||||||
|
|
Loading…
Add table
Reference in a new issue