Skip to content

Commit

Permalink
Update workflow, add issue template
Browse files Browse the repository at this point in the history
  • Loading branch information
zaelgohary committed Aug 7, 2024
1 parent 3717d59 commit e6675fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Someone just pushed
labels: bug
---
58 changes: 13 additions & 45 deletions .github/workflows/issue_creation.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,23 @@
name: Create Issue if Not Exists

on:
# .github/workflows/issue-on-push.yml
on:
push:
branches:
- development_issue_creation

permissions:
contents: read
issues: write
jobs:
create_issue:
stuff:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set issue title and body
id: set_issue
run: |
ISSUE_TITLE="New Issue Title"
ISSUE_BODY="This is the body of the new issue."
echo "::set-output name=issue_title::$ISSUE_TITLE"
echo "::set-output name=issue_body::$ISSUE_BODY"
- name: Check for existing issues
id: check_issue
uses: actions/github-script@v6
- uses: actions/checkout@v3
- uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const title = process.env.ISSUE_TITLE;
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
const issueExists = issues.some(issue => issue.title === title);
return { issueExists: issueExists };
- name: Create a new issue if not exists
if: steps.check_issue.outputs.issueExists == 'false'
uses: actions/github-script@v6
with:
script: |
const title = process.env.ISSUE_TITLE;
const body = process.env.ISSUE_BODY;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body
});
- name: Issue already exists
if: steps.check_issue.outputs.issueExists == 'true'
run: echo "Issue with title '${{ steps.set_issue.outputs.issue_title }}' already exists."
search_existing: all
filename: .github/issue_template.md

0 comments on commit e6675fd

Please sign in to comment.