From 88bc5887a2b3a1adb8993bfcc53dc060b436b1d1 Mon Sep 17 00:00:00 2001 From: pdettmann <57445176+pdettmann@users.noreply.github.com> Date: Thu, 19 May 2022 16:41:01 +0200 Subject: [PATCH 1/5] Update my-workflow.yml --- .github/workflows/my-workflow.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/my-workflow.yml b/.github/workflows/my-workflow.yml index 89e7fe7..85e29ef 100644 --- a/.github/workflows/my-workflow.yml +++ b/.github/workflows/my-workflow.yml @@ -16,3 +16,11 @@ jobs: - name: meow uses: ./.github/actions/cat-facts + id: cat + + - name: create-issue + uses: ./.github/actions/issue-maker + with: + repoToken: ${{secrets.GITHUB_TOKEN}} + catFact: ${{steps.cat.outputs.fact}} + issueTitle: "a cat fact for you" From 6067ef8bd6d2813db511a9dac6af974acf9d3b6c Mon Sep 17 00:00:00 2001 From: pdettmann <57445176+pdettmann@users.noreply.github.com> Date: Thu, 19 May 2022 16:43:22 +0200 Subject: [PATCH 2/5] Create package.json --- .github/actions/issue-maker/package.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/actions/issue-maker/package.json diff --git a/.github/actions/issue-maker/package.json b/.github/actions/issue-maker/package.json new file mode 100644 index 0000000..e26c1bf --- /dev/null +++ b/.github/actions/issue-maker/package.json @@ -0,0 +1,16 @@ +{ + "name": "issue-maker", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@actions/core": "^1.2.2", + "@actions/github": "^2.1.0" + } +} From 17cdacac2f7b86195509b8a489a904e7c39d788c Mon Sep 17 00:00:00 2001 From: pdettmann <57445176+pdettmann@users.noreply.github.com> Date: Thu, 19 May 2022 16:49:07 +0200 Subject: [PATCH 3/5] Create action.yml --- .github/actions/issue-maker/action.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/actions/issue-maker/action.yml diff --git a/.github/actions/issue-maker/action.yml b/.github/actions/issue-maker/action.yml new file mode 100644 index 0000000..ba0e283 --- /dev/null +++ b/.github/actions/issue-maker/action.yml @@ -0,0 +1,22 @@ +name: "issue maker" + +description: "create and issue with a cat fact as the body" + +inputs: + issueTitle: + description: "A name for the cat-fact issue" + required: true + default: "A cat fact for you" + + catFact: + description: "the cat fact retreived from a previous action" + required: true + default: "Mona is an Octocat" + + repoToken: + description: "Authentication token, use secrets.GITHUB_TOKEN" + required: true + +runs: + using: "docker" + image: "Dockerfile" From 0c12a4a81378fce31f487ed700baab71a2126657 Mon Sep 17 00:00:00 2001 From: pdettmann <57445176+pdettmann@users.noreply.github.com> Date: Thu, 19 May 2022 16:49:29 +0200 Subject: [PATCH 4/5] Create index.js --- .github/actions/issue-maker/src/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/actions/issue-maker/src/index.js diff --git a/.github/actions/issue-maker/src/index.js b/.github/actions/issue-maker/src/index.js new file mode 100644 index 0000000..eee2215 --- /dev/null +++ b/.github/actions/issue-maker/src/index.js @@ -0,0 +1,23 @@ +const core = require("@actions/core"); +const github = require("@actions/github"); + +async function run() { + const issueTitle = core.getInput("issueTitle"); + const catFact = core.getInput("catFact"); + + const token = core.getInput("repoToken"); + try { + const octokit = new github.GitHub(token); + + const newIssue = await octokit.issues.create({ + repo: github.context.repo.repo, + owner: github.context.repo.owner, + title: issueTitle, + body: catFact + }); + } catch (error) { + core.setFailed(error.message); + } +} + +run(); From 54f1bcc5b5b123a7f1447167f6ce284a0d303296 Mon Sep 17 00:00:00 2001 From: pdettmann <57445176+pdettmann@users.noreply.github.com> Date: Thu, 19 May 2022 16:50:04 +0200 Subject: [PATCH 5/5] Create Dockerfile --- .github/actions/issue-maker/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/actions/issue-maker/Dockerfile diff --git a/.github/actions/issue-maker/Dockerfile b/.github/actions/issue-maker/Dockerfile new file mode 100644 index 0000000..c7c31cf --- /dev/null +++ b/.github/actions/issue-maker/Dockerfile @@ -0,0 +1,9 @@ +FROM node:slim + +COPY package*.json ./ + +RUN npm install + +COPY . . + +CMD [ "node", "/src/index.js" ]