diff --git a/action.yml b/action.yml index 5ea23fa..6b35c40 100644 --- a/action.yml +++ b/action.yml @@ -48,58 +48,74 @@ runs: run: | 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 # - files=(*.pkg.tar.zst) - echo "Files discovered: ${files}" - echo "inputs.package = ${{ inputs.package }}" + echo '::group::Package' + FILES=(*.pkg.tar.zst) + echo "Files discovered: ${FILES}" + echo 'inputs.package = ${{ inputs.package }}' if [ -n '${{ inputs.package }}' ]; then - if [[ "${#files[@]}" == 1 ]]; then - - echo "Setting package to ${files[0]}" - echo "::set-output name=package::${files[0]}" + if [[ "${#FILES[@]}" == 1 ]]; then + echo "Setting package to ${FILES[0]}" + echo "::set-output name=package::${FILES[0]}" 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 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 # - echo "gitea.actor = ${{ gitea.actor }}" - echo "inputs.username = ${{ inputs.username }}" + echo '::group::Username' + echo 'gitea.actor = ${{ gitea.actor }}' + echo 'inputs.username = ${{ inputs.username }}' USERNAME='${{ gitea.actor }}' if [ -n '${{ inputs.username }}' ]; then USERNAME='${{ inputs.username }}' fi echo "Setting username to ${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::' @@ -110,18 +126,15 @@ runs: curl --version 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' RESPONSE=$( - curl -X PUT "${PACKAGE_URL}" \ + curl -X PUT '${{ steps.prepared.outputs.package_url }}' \ --silent \ --verbose \ --write-out '\n%{http_code}' \ --user '${{ steps.prepared.outputs.username }}:${{ inputs.PERSONAL_ACCESS_TOKEN }}' \ --header 'Content-Type: application/octet-stream' \ - --data-binary "@${{ steps.prepared.outputs.package }}" + --data-binary '@${{ steps.prepared.outputs.package }}' ) echo '::endgroup::' @@ -136,6 +149,9 @@ runs: echo "${HTTP_CODE}" echo '::endgroup::' + # + # Handle Result + # if ((HTTP_CODE >= 200 && HTTP_CODE <= 399)); then # Success echo 'The package ${{ steps.prepared.outputs.package }} was successfully pushed to the package registry'