name: "Gitea Auto-PR (Github and Gitea Compatible)" description: "Gitea-compatible version of https://github.com/arifer612/Gitea-PR-action" branding: icon: "git-pull-request" color: "green" inputs: url: description: URL to the Gitea instance required: true token: description: Personal access token to the Gitea instance required: true tea-version: description: Tea CLI version default: 0.10.1 pr-title: description: Custom title. Defaults to using subject of the most recent commit. pr-description: description: Custom description. Defaults to using body of the most recent commit. pr-label: description: Labels for the PR (comma-separated) assignee: description: User to assign the PR to default: ${{ github.actor }} outputs: pr_number: description: The PR index/number that exists or was created value: ${{ steps.set-pr-output.outputs.pr_number }} runs: using: "composite" steps: - name: Install Tea env: TEA_DL_URL: "https://dl.gitea.com/tea/${{ inputs.tea-version }}/tea-${{ inputs.tea-version }}-linux-amd64" shell: bash run: | cd /tmp wget -q "${TEA_DL_URL}" wget -q "${TEA_DL_URL}.sha256" if $(sha256sum --quiet -c "tea-${{ inputs.tea-version }}-linux-amd64.sha256"); then mv "tea-${{ inputs.tea-version }}-linux-amd64" /usr/bin/tea chmod +x /usr/bin/tea else echo "WARNING ⛔: Tea v${{ inputs.tea-version }} Checksum Failed" exit 1 fi - name: Login to Gitea shell: bash env: GIT_SERVER_URL: ${{ inputs.url }} GIT_SERVER_TOKEN: ${{ inputs.token }} run: | tea login add --url "$GIT_SERVER_URL" --token "$GIT_SERVER_TOKEN" - name: Check if open PR exists shell: bash id: check-opened-pr-step continue-on-error: true run: | echo "Checking for PR... 🔎" pr_number=$(tea pr list \ --repo ${{ github.repository }} \ --state open \ --fields index,head \ --output simple \ | egrep "${{ github.ref_name }}" \ | awk '{print $1}') echo "pr_number=$pr_number" >> $GITHUB_OUTPUT - name: Skip PR Creation if: steps.check-opened-pr-step.outputs.pr_number != '' shell: bash run: | echo -e "✅ A PR already exists for ${{ github.ref_name }} (PR #${{ steps.check-opened-pr-step.outputs.pr_number }})" - name: PR Creation shell: bash if: steps.check-opened-pr-step.outputs.pr_number == '' id: pr-creation env: PR_TITLE: ${{ inputs.pr-title }} PR_DESCRIP: ${{ inputs.pr-description }} run: | if [ -z "${PR_TITLE}" ]; then PR_TITLE=$(git log -n 1 --format=%s) fi if [ -z "${PR_DESCRIP}" ]; then PR_DESCRIP=$(git log -n 1 --format=%b) fi created_pr_index=$(tea pr c -r ${{ github.repository }} \ -t "${PR_TITLE}" \ -d "${PR_DESCRIP}" \ -a ${{ inputs.assignee }} \ -L "${{ inputs.pr-label }}" \ --output simple \ | awk '{print $1}') echo "PR Created 🎫 (PR #$created_pr_index)" echo "created_pr_index=$created_pr_index" >> $GITHUB_OUTPUT - name: Set unified PR number output id: set-pr-output shell: bash env: EXISTING_PR: ${{ steps.check-opened-pr-step.outputs.pr_number }} CREATED_PR: ${{ steps.pr-creation.outputs.created_pr_index }} run: | if [ -n "$EXISTING_PR" ]; then echo "pr_number=$EXISTING_PR" >> $GITHUB_OUTPUT else echo "pr_number=$CREATED_PR" >> $GITHUB_OUTPUT