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" ] 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" 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" + } +} 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(); 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"