Skip to content

Commit

Permalink
Merge pull request #1 from creative-commoners/pulls/1.0/initial
Browse files Browse the repository at this point in the history
NEW Create action
  • Loading branch information
GuySartorelli authored Jun 13, 2023
2 parents 1a1c06c + 2a45fa8 commit d93ab20
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Auto-tag
on:
push:
tags:
- '*.*.*'
jobs:
auto-tag:
name: Auto-tag
runs-on: ubuntu-latest
steps:
- name: Auto-tag
uses: silverstripe/gha-auto-tag@v1
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# gha-issue
GitHub Action - Creates a new issue with github-actions user as the author
# GitHub Actions - Issue

Create a new issue using a github-actions user as the author. These will be created on the account/repo that called the action.

## Usage

**workflow.yml**
```yml
steps:
- name: Create issue
uses: silverstripe/gha-issue@v1
with:
title: My issue title
description: |
This text will appear in the body of the GitHub issue\n
\n
You can add line breaks\n
\n
## My heading\n
- Markdown is supported\n
```
46 changes: 46 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Create issue
description: GitHub Action to create an issue as the github-actions user

inputs:
title:
type: string
required: true
description:
type: string
required: true

runs:
using: composite
steps:

- name: Create issue
shell: bash
env:
TITLE: ${{ inputs.title }}
DESCRIPTION: ${{ inputs.description }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
# Escape double quotes '"' => '\"'
TITLE=${TITLE//\"/\\\"}
DESCRIPTION=${DESCRIPTION//\"/\\\"}
# Create new pull-request via GitHub API
# https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue
RESP_CODE=$(curl -w %{http_code} -s -o /dev/null \
-X POST https://api.github.com/repos/$GITHUB_REPOSITORY/issues \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d @- << EOF
{
"title": "$TITLE",
"body": "$DESCRIPTION"
}
EOF
)
if [[ $RESP_CODE == "201" ]]; then
echo "New issue created"
else
echo "Fail to create issue - HTTP response code was $RESP_CODE"
exit 1
fi

0 comments on commit d93ab20

Please sign in to comment.