80 lines
2.4 KiB
YAML
80 lines
2.4 KiB
YAML
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.11.0
|
|
pr-label:
|
|
description: Labels for the PR (comma-separated)
|
|
assignee:
|
|
description: User to assign the PR to
|
|
default: ${{ github.actor }}
|
|
|
|
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
|
|
-u "$GIT_SERVER_URL"
|
|
-t "$GIT_SERVER_TOKEN"
|
|
- name: Check if open PR exists
|
|
shell: bash
|
|
id: check-opened-pr-step
|
|
continue-on-error: true
|
|
run: |
|
|
pr_exists=$(tea pr list \
|
|
--repo ${{ github.repository }} \
|
|
--state open \
|
|
--fields head \
|
|
--output simple \
|
|
| egrep '${{ github.ref_name }}' | wc -l)
|
|
|
|
echo "exists=$pr_exists" >> $GITHUB_OUTPUT
|
|
- name: Skip PR Creation
|
|
if: steps.check-opened-pr-step.outputs.exists == '1'
|
|
shell: bash
|
|
run: |
|
|
echo -e "✅ A PR already exists for ${{ gitea.ref_name }}\nSkipping PR creation..."\
|
|
- name: PR Creation
|
|
shell: bash
|
|
if: steps.check-opened-pr-step.outputs.exists == '0'
|
|
run: |
|
|
PR_TITLE=$(git log -n 1 --format=%s)
|
|
PR_DESCRIP=$(git log -n 1 --format=%b)
|
|
tea pr c -r ${{ github.repository }} \
|
|
-t "${PR_TITLE}" \
|
|
-d "${PR_DESCRIP}" \
|
|
-a ${{ github.actor }} \
|
|
-L ${{ inputs.pr-label }}
|