Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Create action #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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