From bfbf30393905df3f600fc268f58a0ba6dc548826 Mon Sep 17 00:00:00 2001 From: "Mr. Wang" <77764945+first-coding@users.noreply.github.com> Date: Mon, 30 May 2022 23:53:16 +0800 Subject: [PATCH 1/5] Update my-workflow.yml --- .github/workflows/my-workflow.yml | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/my-workflow.yml b/.github/workflows/my-workflow.yml index ec5614e..85e29ef 100644 --- a/.github/workflows/my-workflow.yml +++ b/.github/workflows/my-workflow.yml @@ -1,31 +1,26 @@ -# This is a basic workflow to help you get started with Actions - name: Docker Actions -# Controls when the workflow will run -on: [push] - # Triggers the workflow on push or pull request events but only for the main branch - -# # Allows you to run this workflow manually from the Actions tab -# workflow_dispatch: +on: + pull_request: + types: [labeled] -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: action: runs-on: ubuntu-latest - # This workflow contains a single job called "build" - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v1 - # Runs a single command using the runners shell - name: hello-action uses: ./.github/actions/hello-world - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. + - 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 465d49366f6a5e2ed61308d7dc1eb3a2960ab219 Mon Sep 17 00:00:00 2001 From: "Mr. Wang" <77764945+first-coding@users.noreply.github.com> Date: Tue, 31 May 2022 23:40:17 +0800 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 2e3490b9dc3edb159d20367e5224f10b3ddb67e8 Mon Sep 17 00:00:00 2001 From: "Mr. Wang" <77764945+first-coding@users.noreply.github.com> Date: Tue, 31 May 2022 23:45:25 +0800 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 aae8808618937a2f8bb0aeb239407b117d28c209 Mon Sep 17 00:00:00 2001 From: "Mr. Wang" <77764945+first-coding@users.noreply.github.com> Date: Tue, 31 May 2022 23:48:28 +0800 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 32e1037af05084a5a9cdd9c1cda20616723476fd Mon Sep 17 00:00:00 2001 From: "Mr. Wang" <77764945+first-coding@users.noreply.github.com> Date: Tue, 31 May 2022 23:49:43 +0800 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" ]