Files
actions/create-pr/action.yaml
Hugo Nijhuis 14d7cae864 Add reusable Forgejo Actions
Composite actions for CI/CD workflows:
- checkout: Clone repo with configurable depth
- docker-build: Build Docker images with multiple tags
- docker-push: Push to Forgejo Packages registry
- create-tag: Auto-increment semantic version tags
- create-issue: Create issues via Forgejo API
- create-pr: Create pull requests via Forgejo API
- comment-pr: Add comments to PRs via Forgejo API

All actions use shell scripts (no Node.js required).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 00:30:07 +01:00

84 lines
2.3 KiB
YAML

name: Create Pull Request
description: Create a pull request via Forgejo API
inputs:
token:
description: Forgejo API token
required: true
repository:
description: Repository (owner/repo)
default: ${{ github.repository }}
title:
description: Pull request title
required: true
body:
description: Pull request body
default: ''
head:
description: Source branch
required: true
base:
description: Target branch
default: 'main'
labels:
description: Comma-separated label names
default: ''
assignees:
description: Comma-separated usernames to assign
default: ''
outputs:
number:
description: Created PR number
value: ${{ steps.create.outputs.number }}
url:
description: PR URL
value: ${{ steps.create.outputs.url }}
runs:
using: composite
steps:
- id: create
shell: bash
run: |
TOKEN="${{ inputs.token }}"
REPO="${{ inputs.repository }}"
TITLE="${{ inputs.title }}"
BODY="${{ inputs.body }}"
HEAD="${{ inputs.head }}"
BASE="${{ inputs.base }}"
LABELS="${{ inputs.labels }}"
ASSIGNEES="${{ inputs.assignees }}"
# Build JSON payload
JSON=$(jq -n \
--arg title "$TITLE" \
--arg body "$BODY" \
--arg head "$HEAD" \
--arg base "$BASE" \
'{title: $title, body: $body, head: $head, base: $base}')
# Add labels if provided
if [ -n "$LABELS" ]; then
LABELS_JSON=$(echo "$LABELS" | tr ',' '\n' | jq -R . | jq -s .)
JSON=$(echo "$JSON" | jq --argjson labels "$LABELS_JSON" '. + {labels: $labels}')
fi
# Add assignees if provided
if [ -n "$ASSIGNEES" ]; then
ASSIGNEES_JSON=$(echo "$ASSIGNEES" | tr ',' '\n' | jq -R . | jq -s .)
JSON=$(echo "$JSON" | jq --argjson assignees "$ASSIGNEES_JSON" '. + {assignees: $assignees}')
fi
RESPONSE=$(curl -s -X POST \
"https://code.flowmade.one/api/v1/repos/$REPO/pulls" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON")
NUMBER=$(echo "$RESPONSE" | jq -r '.number')
URL=$(echo "$RESPONSE" | jq -r '.html_url')
echo "number=$NUMBER" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT