Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahSiegel committed Feb 19, 2024
0 parents commit 6e902c1
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Action

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-action:
name: Test create PR on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout the repo
uses: actions/[email protected]

- name: Create Pull Request
id: create_pr
uses: ./
with:
title: 'Automated Pull Request'
sourceBranch: ${{ github.ref_name }}
targetBranch: 'main'
body: 'This is an automated pull request.'
labels: 'automated,pr'
assignees: 'octocat'

- name: Output PR URL
run: echo "The PR URL is ${{ steps.create_pr.outputs.PRURL }}"
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Remote Branch Action

[![Test Action](https://github.com/JosiahSiegel/reliable-pull-request-action/actions/workflows/test-action.yml/badge.svg)](https://github.com/JosiahSiegel/reliable-pull-request-action/actions/workflows/test-action.yml)

## Synopsis

1. Create a pull request on a GitHub repository using existing branches.
2. [actions/checkout](https://github.com/actions/checkout) determins the active repo.

## Usage

```yml
jobs:
create-pr:
name: Test create PR on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout the repo
uses: actions/[email protected]

- name: Create Pull Request
id: create_pr
uses: josiahsiegel/[email protected]
with:
title: 'Automated Pull Request'
sourceBranch: ${{ github.ref_name }}
targetBranch: 'main'
body: 'This is an automated pull request.'
labels: 'automated,pr'
assignees: 'octocat'

- name: Output PR URL
run: echo "The PR URL is ${{ steps.create_pr.outputs.PRURL }}"
```
## Inputs
```yml
inputs:
title:
description: 'Pull Request Title'
required: true
sourceBranch:
description: 'Source Branch Name'
required: true
targetBranch:
description: 'Target Branch Name'
required: true
body:
description: 'Pull Request Body'
required: false
labels:
description: 'Labels (comma-separated)'
required: false
assignees:
description: 'Assignees (comma-separated)'
required: false
```
## Outputs
```yml
outputs:
PRURL:
description: 'The URL of the created pull request'
```
40 changes: 40 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Reliable Pull Request Action
description: Creates a pull request on a GitHub repository using existing branches
branding:
icon: 'git-pull-request'
color: 'blue'
inputs:
title:
description: 'Pull Request Title'
required: true
sourceBranch:
description: 'Source Branch Name'
required: true
targetBranch:
description: 'Target Branch Name'
required: true
body:
description: 'Pull Request Body'
required: false
labels:
description: 'Labels (comma-separated)'
required: false
assignees:
description: 'Assignees (comma-separated)'
required: false
outputs:
PRURL:
description: 'The URL of the created pull request'
runs:
using: 'composite'
steps:
- name: Create Pull Request
shell: bash
run: bash create-pr.sh
env:
INPUT_TITLE: ${{ inputs.title }}
INPUT_SOURCEBRANCH: ${{ inputs.sourceBranch }}
INPUT_TARGETBRANCH: ${{ inputs.targetBranch }}
INPUT_BODY: ${{ inputs.body }}
INPUT_LABELS: ${{ inputs.labels }}
INPUT_ASSIGNEES: ${{ inputs.assignees }}
16 changes: 16 additions & 0 deletions create-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Create Pull Request and capture the output
PR_OUTPUT=$(gh pr create \
--title "$INPUT_TITLE" \
--body "$INPUT_BODY" \
--base "$INPUT_TARGETBRANCH" \
--head "$INPUT_SOURCEBRANCH" \
--label "$INPUT_LABELS" \
--assignee "$INPUT_ASSIGNEES")

# Extract PR URL from the output
PR_URL=$(echo "$PR_OUTPUT" | grep -o 'https://github.com/[^ ]*')

# Set the PR URL as the output
echo "::set-output name=PRURL::$PR_URL"

0 comments on commit 6e902c1

Please sign in to comment.