diff --git a/action.yaml b/action.yaml index bf17484..0b39365 100644 --- a/action.yaml +++ b/action.yaml @@ -5,7 +5,7 @@ inputs: gitea_url: description: "Base URL of the Gitea instance" required: false - default: "https://gitea.psi.ch" + default: "" repository: description: "Target repository as owner/repo" required: false @@ -49,54 +49,39 @@ runs: - id: create_pr name: Create Pull Request shell: bash - env: - INPUT_GITEA_URL: ${{ inputs.gitea_url }} - INPUT_REPOSITORY: ${{ inputs.repository }} - INPUT_TOKEN: ${{ inputs.token }} - INPUT_TITLE: ${{ inputs.title }} - INPUT_BODY: ${{ inputs.body }} - INPUT_HEAD: ${{ inputs.head }} - INPUT_BASE: ${{ inputs.base }} - INPUT_ALLOW_EXISTING: ${{ inputs.allow_existing }} - GITHUB_REPOSITORY: ${{ github.repository }} run: | set -euo pipefail - GITEA_URL="${INPUT_GITEA_URL:-https://gitea.psi.ch}" - REPOSITORY="${INPUT_REPOSITORY:-${GITHUB_REPOSITORY}}" - HEAD="${INPUT_HEAD}" - BASE="${INPUT_BASE:-main}" - ALLOW_EXISTING="${INPUT_ALLOW_EXISTING:-true}" + GITEA_URL="${{ inputs.gitea_url }}" + GITEA_URL="${GITEA_URL:-${{ github.server_url }}}" + + REPOSITORY="${{ inputs.repository }}" + REPOSITORY="${REPOSITORY:-${{ github.repository }}}" + + TOKEN="${{ inputs.token }}" + TITLE="${{ inputs.title }}" + BODY="${{ inputs.body }}" + HEAD="${{ inputs.head }}" + BASE="${{ inputs.base }}" + BASE="${BASE:-main}" + ALLOW_EXISTING="${{ inputs.allow_existing }}" + ALLOW_EXISTING="${ALLOW_EXISTING:-true}" if [[ ! "${REPOSITORY}" =~ ^[^/]+/[^/]+$ ]]; then echo "::error::repository must be owner/repo, got: ${REPOSITORY}" exit 1 fi - if [ -z "${INPUT_TOKEN}" ]; then - echo "::error::token is required" - exit 1 - fi - - if [ -z "${INPUT_TITLE}" ]; then - echo "::error::title is required" - exit 1 - fi - - if [ -z "${HEAD}" ]; then - echo "::error::head is required" - exit 1 - fi API_BASE="${GITEA_URL}/api/v1/repos/${REPOSITORY}" - AUTH_HEADER="Authorization: token ${INPUT_TOKEN}" + AUTH_HEADER="Authorization: token ${TOKEN}" echo "::notice::Creating pull request ${REPOSITORY}: ${HEAD} -> ${BASE}" PAYLOAD="$( jq -n \ - --arg title "${INPUT_TITLE}" \ - --arg body "${INPUT_BODY}" \ + --arg title "${TITLE}" \ + --arg body "${BODY}" \ --arg head "${HEAD}" \ --arg base "${BASE}" \ '{title: $title, body: $body, head: $head, base: $base}'