From 689274e663751941b5195b23fe6181bddfc21e03 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 19:39:35 +0300 Subject: [PATCH 01/15] test commit --- .github/workflows/create_pull_request.yml | 21 ----- .github/workflows/develop_actions.yml | 16 ++++ .github/workflows/merge_pull_request.yml | 18 ---- .github/workflows/npm-gulp.yml | 37 -------- gulpfile.js | 105 ++++++++++++++++++--- package-lock.json | 109 ++++++++++++++++++++++ package.json | 2 + src/develop_actions.js | 18 ++++ 8 files changed, 237 insertions(+), 89 deletions(-) delete mode 100644 .github/workflows/create_pull_request.yml create mode 100644 .github/workflows/develop_actions.yml delete mode 100644 .github/workflows/merge_pull_request.yml delete mode 100644 .github/workflows/npm-gulp.yml create mode 100644 src/develop_actions.js diff --git a/.github/workflows/create_pull_request.yml b/.github/workflows/create_pull_request.yml deleted file mode 100644 index d9d1eb5..0000000 --- a/.github/workflows/create_pull_request.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Pull Request Action -on: - push: - branches: - - feature/* - - test/* - - test - -jobs: - create-pull-request: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v2 - - name: pull-request - uses: repo-sync/pull-request@v2 - with: - destination_branch: "develop" - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_label: "feature, automated pr" - pr_title: "[Example] Simple demo" \ No newline at end of file diff --git a/.github/workflows/develop_actions.yml b/.github/workflows/develop_actions.yml new file mode 100644 index 0000000..caf4e8e --- /dev/null +++ b/.github/workflows/develop_actions.yml @@ -0,0 +1,16 @@ +name: on merging to develop + +on: + push: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ./develop_actions.js + with: + GITHUB_TOKEN: ${{secrets.TOKEN}} + \ No newline at end of file diff --git a/.github/workflows/merge_pull_request.yml b/.github/workflows/merge_pull_request.yml deleted file mode 100644 index 9eef387..0000000 --- a/.github/workflows/merge_pull_request.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: test - -on: - pull_request: - branches: [master, develop, staging] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Check Out Repo - uses: actions/checkout@v2 - - # - name: 🔀 Merge Pull Request - # uses: BaharaJr/merge-pr@0.0.1 - # with: - # GITHUB_TOKEN: ${{ secrets.TOKEN }} \ No newline at end of file diff --git a/.github/workflows/npm-gulp.yml b/.github/workflows/npm-gulp.yml deleted file mode 100644 index 3f12365..0000000 --- a/.github/workflows/npm-gulp.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: NodeJS with Gulp - -on: - push: - branches: [ develop ] - paths: ["gulpfile.js"] - pull_request: - branches: [ develop ] - paths: ["gulpfile.js"] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - node-version: [12.x, 14.x, 16.x] - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Build - run: npm install - - - name: gulp - run: npm install -g gulp axios @octokit/core - - - name: notify - # run: gulp createnotification --b ${{ secrets.SLACK_WEBHOOK_URL }} - run: gulp getpulls --b ${{ secrets.TOKEN }} - diff --git a/gulpfile.js b/gulpfile.js index aad22fe..ed14678 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -87,10 +87,10 @@ gulp.task("getpulls", async () => { }); console.log("pulls", pulls?.data); - const pull = await octokit.request("GET /repos/bmsteven/demo/pulls/16", { + const pull = await octokit.request("GET /repos/bmsteven/demo/pulls/18", { owner: "bmsteven", repo: "demo", - pull_number: "16", + pull_number: "18", }); console.log("pull", pull?.data); // update pull request @@ -109,27 +109,27 @@ gulp.task("getpulls", async () => { { owner: "bmsteven", repo: "demo", - pull_number: "16", + pull_number: "18", } ); console.log("commits", commits?.data); // check if pull request was merged - // const checkPulls = await octokit.request( - // "GET /repos/bmsteven/demo/pulls/16/merge", - // { - // owner: "bmsteven", - // repo: "demo", - // pull_number: "16", - // } - // ); - // console.log("checkPulls", checkPulls?.data); + const checkPulls = await octokit.request( + "GET /repos/bmsteven/demo/pulls/18/merge", + { + owner: "bmsteven", + repo: "demo", + pull_number: "18", + } + ); + console.log("checkPulls", checkPulls?.data); // merge pull request const mergepr = await octokit.request( "PUT /repos/bmsteven/demo/pulls/16/merge", { owner: "bmsteven", repo: "demo", - pull_number: "16", + pull_number: "18", } ); console.log("mergepr", mergepr?.data); @@ -163,3 +163,82 @@ gulp.task("getpulls", async () => { // run: echo "This step will be skipped on Monday and Wednesday" // - name: Every time // run: echo "This step will always run" + +// create pr action +// name: Pull Request Action +// on: +// push: +// branches: +// - feature/* +// - test/* +// - test + +// jobs: +// create-pull-request: +// runs-on: ubuntu-latest +// steps: +// - name: Check out repository code +// uses: actions/checkout@v2 +// - name: pull-request +// uses: repo-sync/pull-request@v2 +// with: +// destination_branch: "develop" +// github_token: ${{ secrets.GITHUB_TOKEN }} +// pr_label: "feature, automated pr" +// pr_title: "[Example] Simple demo" + +// name: test + +// on: +// pull_request: +// branches: [master, develop, staging] + +// jobs: +// build: +// runs-on: ubuntu-latest + +// steps: +// - name: Check Out Repo +// uses: actions/checkout@v2 + +// # - name: 🔀 Merge Pull Request +// # uses: BaharaJr/merge-pr@0.0.1 +// # with: +// # GITHUB_TOKEN: ${{ secrets.TOKEN }} + +// name: NodeJS with Gulp + +// on: +// push: +// branches: [ develop ] +// paths: ["gulpfile.js"] +// pull_request: +// branches: [ develop ] +// paths: ["gulpfile.js"] + +// jobs: +// build: +// runs-on: ubuntu-latest + +// strategy: +// fail-fast: false +// matrix: +// node-version: [12.x, 14.x, 16.x] + +// steps: +// - uses: actions/checkout@v3 + +// - name: Use Node.js ${{ matrix.node-version }} +// uses: actions/setup-node@v3 +// with: +// node-version: ${{ matrix.node-version }} + +// - name: Build +// run: npm install + +// - name: gulp +// run: npm install -g gulp axios @octokit/core + +// - name: notify +// # run: gulp createnotification --b ${{ secrets.SLACK_WEBHOOK_URL }} +// run: gulp getpulls --b ${{ secrets.TOKEN }} diff --git a/package-lock.json b/package-lock.json index e3033c5..d38c1b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,40 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@actions/core": "^1.6.0", + "@actions/github": "^5.0.1", "@octokit/core": "^3.6.0", "axios": "^0.26.1", "gulp": "^4.0.2" } }, + "node_modules/@actions/core": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", + "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", + "dependencies": { + "@actions/http-client": "^1.0.11" + } + }, + "node_modules/@actions/github": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.1.tgz", + "integrity": "sha512-JZGyPM9ektb8NVTTI/2gfJ9DL7Rk98tQ7OVyTlgTuaQroariRBsOnzjy0I2EarX4xUZpK88YyO503fhmjFdyAg==", + "dependencies": { + "@actions/http-client": "^1.0.11", + "@octokit/core": "^3.6.0", + "@octokit/plugin-paginate-rest": "^2.17.0", + "@octokit/plugin-rest-endpoint-methods": "^5.13.0" + } + }, + "node_modules/@actions/http-client": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", + "dependencies": { + "tunnel": "0.0.6" + } + }, "node_modules/@octokit/auth-token": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", @@ -61,6 +90,29 @@ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-11.2.0.tgz", "integrity": "sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==" }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz", + "integrity": "sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==", + "dependencies": { + "@octokit/types": "^6.34.0" + }, + "peerDependencies": { + "@octokit/core": ">=2" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz", + "integrity": "sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==", + "dependencies": { + "@octokit/types": "^6.34.0", + "deprecation": "^2.3.1" + }, + "peerDependencies": { + "@octokit/core": ">=3" + } + }, "node_modules/@octokit/request": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", @@ -3437,6 +3489,14 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, "node_modules/type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", @@ -3789,6 +3849,33 @@ } }, "dependencies": { + "@actions/core": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", + "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", + "requires": { + "@actions/http-client": "^1.0.11" + } + }, + "@actions/github": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.0.1.tgz", + "integrity": "sha512-JZGyPM9ektb8NVTTI/2gfJ9DL7Rk98tQ7OVyTlgTuaQroariRBsOnzjy0I2EarX4xUZpK88YyO503fhmjFdyAg==", + "requires": { + "@actions/http-client": "^1.0.11", + "@octokit/core": "^3.6.0", + "@octokit/plugin-paginate-rest": "^2.17.0", + "@octokit/plugin-rest-endpoint-methods": "^5.13.0" + } + }, + "@actions/http-client": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", + "requires": { + "tunnel": "0.0.6" + } + }, "@octokit/auth-token": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", @@ -3836,6 +3923,23 @@ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-11.2.0.tgz", "integrity": "sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==" }, + "@octokit/plugin-paginate-rest": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz", + "integrity": "sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==", + "requires": { + "@octokit/types": "^6.34.0" + } + }, + "@octokit/plugin-rest-endpoint-methods": { + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz", + "integrity": "sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==", + "requires": { + "@octokit/types": "^6.34.0", + "deprecation": "^2.3.1" + } + }, "@octokit/request": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", @@ -6500,6 +6604,11 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + }, "type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", diff --git a/package.json b/package.json index 75a2f55..c2e77e2 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ }, "homepage": "https://github.com/bmsteven/demo#readme", "dependencies": { + "@actions/core": "^1.6.0", + "@actions/github": "^5.0.1", "@octokit/core": "^3.6.0", "axios": "^0.26.1", "gulp": "^4.0.2" diff --git a/src/develop_actions.js b/src/develop_actions.js new file mode 100644 index 0000000..c188676 --- /dev/null +++ b/src/develop_actions.js @@ -0,0 +1,18 @@ +const axios = require("axios"); +const github = require("@actions/github"); +const core = require("@actions/core"); + +const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN"); +const octokit = github.getOctokit(GITHUB_TOKEN); +const { context = {} } = github; + +const run = async () => { + console.log(context.payload); + console.log(GITHUB_TOKEN); + console.log("actions"); +}; + +run(); + +// $GITHUB_REF would look like (refs/pull/33/merge), $GITHUB_HEAD_REF would just store the source branch name while $GITHUB_BASE_REF would represent RP destination branch. Maybe you can update your answer to fallback to $GITHUB_HEAD_REF +// ${GITHUB_REF##*/} From 551fb697c20b284f9d61f78aead0310eb4bf330d Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 19:45:29 +0300 Subject: [PATCH 02/15] test commit --- action.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..eb49f45 --- /dev/null +++ b/action.yml @@ -0,0 +1,15 @@ +name: 'Automatically create pr to staging' +description: 'Run develop actions' +author: 'Benedict Steven' + +inputs: + GITHUB_TOKEN: + description: 'GitHub Token' + required: true +runs: + using: 'node16' + main: 'develop_actions/index.js' + +branding: + icon: 'package' + color: 'gray-dark' \ No newline at end of file From e8eab07fa57545df3489a8d5276748ca94b38a77 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 19:48:14 +0300 Subject: [PATCH 03/15] test commit --- .github/workflows/develop_actions.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/develop_actions.yml b/.github/workflows/develop_actions.yml index caf4e8e..93e5023 100644 --- a/.github/workflows/develop_actions.yml +++ b/.github/workflows/develop_actions.yml @@ -10,7 +10,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: ./develop_actions.js + - uses: ./ with: GITHUB_TOKEN: ${{secrets.TOKEN}} - \ No newline at end of file From e84c618a59b99f63cfc248891b65804bfba1e9f5 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 19:56:15 +0300 Subject: [PATCH 04/15] test commit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index eb49f45..6d290fe 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: required: true runs: using: 'node16' - main: 'develop_actions/index.js' + main: './src/develop_actions.js' branding: icon: 'package' From 49f9be33fb8cbf34c5a891db989e3de07c27b7a1 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:00:25 +0300 Subject: [PATCH 05/15] test commit --- .github/workflows/develop_actions.yml | 5 +++++ src/develop_actions.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/develop_actions.yml b/.github/workflows/develop_actions.yml index 93e5023..132ef76 100644 --- a/.github/workflows/develop_actions.yml +++ b/.github/workflows/develop_actions.yml @@ -10,6 +10,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Build + run: npm install + + - name: gulp + run: npm install -g gulp axios @octokit/core @actions/github @actions/core - uses: ./ with: GITHUB_TOKEN: ${{secrets.TOKEN}} diff --git a/src/develop_actions.js b/src/develop_actions.js index c188676..956fa00 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -9,7 +9,7 @@ const { context = {} } = github; const run = async () => { console.log(context.payload); console.log(GITHUB_TOKEN); - console.log("actions"); + console.log("test actions"); }; run(); From 67e1dcaef0bb36946998e4992b16ee7ad71e113b Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:15:12 +0300 Subject: [PATCH 06/15] test creating pr to staging --- .github/workflows/develop_actions.yml | 2 +- res.js | 194 ++++++++++++++++++++++++++ src/develop_actions.js | 20 ++- 3 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 res.js diff --git a/.github/workflows/develop_actions.yml b/.github/workflows/develop_actions.yml index 132ef76..f6e8c1e 100644 --- a/.github/workflows/develop_actions.yml +++ b/.github/workflows/develop_actions.yml @@ -13,7 +13,7 @@ jobs: - name: Build run: npm install - - name: gulp + - name: install packages run: npm install -g gulp axios @octokit/core @actions/github @actions/core - uses: ./ with: diff --git a/res.js b/res.js new file mode 100644 index 0000000..81268c3 --- /dev/null +++ b/res.js @@ -0,0 +1,194 @@ +exports.response = { + after: "94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da", + base_ref: null, + before: "cc8b67c069125765f31ee6908392e0439f0d04eb", + commits: [ + { + author: [Object], + committer: [Object], + distinct: false, + id: "49f9be33fb8cbf34c5a891db989e3de07c27b7a1", + message: "test commit", + timestamp: "2022-04-22T20:00:25+03:00", + tree_id: "969c2c9cb3ca68847fcf744a21df3672c153127d", + url: "https://github.com/bmsteven/demo/commit/49f9be33fb8cbf34c5a891db989e3de07c27b7a1", + }, + { + author: [Object], + committer: [Object], + distinct: true, + id: "94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da", + message: + "Merge pull request #22 from bmsteven/test_branch\n\ntest commit", + timestamp: "2022-04-22T20:01:07+03:00", + tree_id: "969c2c9cb3ca68847fcf744a21df3672c153127d", + url: "https://github.com/bmsteven/demo/commit/94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da", + }, + ], + compare: + "https://github.com/bmsteven/demo/compare/cc8b67c06912...94a28b830c5a", + created: false, + deleted: false, + forced: false, + head_commit: { + author: { + email: "48621248+bmsteven@users.noreply.github.com", + name: "Benedict Steven", + username: "bmsteven", + }, + committer: { + email: "noreply@github.com", + name: "GitHub", + username: "web-flow", + }, + distinct: true, + id: "94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da", + message: "Merge pull request #22 from bmsteven/test_branch\n\ntest commit", + timestamp: "2022-04-22T20:01:07+03:00", + tree_id: "969c2c9cb3ca68847fcf744a21df3672c153127d", + url: "https://github.com/bmsteven/demo/commit/94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da", + }, + pusher: { + email: "48621248+bmsteven@users.noreply.github.com", + name: "bmsteven", + }, + ref: "refs/heads/develop", + repository: { + allow_forking: true, + archive_url: + "https://api.github.com/repos/bmsteven/demo/{archive_format}{/ref}", + archived: false, + assignees_url: + "https://api.github.com/repos/bmsteven/demo/assignees{/user}", + blobs_url: "https://api.github.com/repos/bmsteven/demo/git/blobs{/sha}", + branches_url: + "https://api.github.com/repos/bmsteven/demo/branches{/branch}", + clone_url: "https://github.com/bmsteven/demo.git", + collaborators_url: + "https://api.github.com/repos/bmsteven/demo/collaborators{/collaborator}", + comments_url: + "https://api.github.com/repos/bmsteven/demo/comments{/number}", + commits_url: "https://api.github.com/repos/bmsteven/demo/commits{/sha}", + compare_url: + "https://api.github.com/repos/bmsteven/demo/compare/{base}...{head}", + contents_url: "https://api.github.com/repos/bmsteven/demo/contents/{+path}", + contributors_url: "https://api.github.com/repos/bmsteven/demo/contributors", + created_at: 1553584187, + default_branch: "master", + deployments_url: "https://api.github.com/repos/bmsteven/demo/deployments", + description: "demo repository", + disabled: false, + downloads_url: "https://api.github.com/repos/bmsteven/demo/downloads", + events_url: "https://api.github.com/repos/bmsteven/demo/events", + fork: false, + forks: 0, + forks_count: 0, + forks_url: "https://api.github.com/repos/bmsteven/demo/forks", + full_name: "bmsteven/demo", + git_commits_url: + "https://api.github.com/repos/bmsteven/demo/git/commits{/sha}", + git_refs_url: "https://api.github.com/repos/bmsteven/demo/git/refs{/sha}", + git_tags_url: "https://api.github.com/repos/bmsteven/demo/git/tags{/sha}", + git_url: "git://github.com/bmsteven/demo.git", + has_downloads: true, + has_issues: true, + has_pages: false, + has_projects: true, + has_wiki: true, + homepage: null, + hooks_url: "https://api.github.com/repos/bmsteven/demo/hooks", + html_url: "https://github.com/bmsteven/demo", + id: 177733530, + is_template: false, + issue_comment_url: + "https://api.github.com/repos/bmsteven/demo/issues/comments{/number}", + issue_events_url: + "https://api.github.com/repos/bmsteven/demo/issues/events{/number}", + issues_url: "https://api.github.com/repos/bmsteven/demo/issues{/number}", + keys_url: "https://api.github.com/repos/bmsteven/demo/keys{/key_id}", + labels_url: "https://api.github.com/repos/bmsteven/demo/labels{/name}", + language: "JavaScript", + languages_url: "https://api.github.com/repos/bmsteven/demo/languages", + license: null, + master_branch: "master", + merges_url: "https://api.github.com/repos/bmsteven/demo/merges", + milestones_url: + "https://api.github.com/repos/bmsteven/demo/milestones{/number}", + mirror_url: null, + name: "demo", + node_id: "MDEwOlJlcG9zaXRvcnkxNzc3MzM1MzA=", + notifications_url: + "https://api.github.com/repos/bmsteven/demo/notifications{?since,all,participating}", + open_issues: 0, + open_issues_count: 0, + owner: { + avatar_url: "https://avatars.githubusercontent.com/u/48621248?v=4", + email: "48621248+bmsteven@users.noreply.github.com", + events_url: "https://api.github.com/users/bmsteven/events{/privacy}", + followers_url: "https://api.github.com/users/bmsteven/followers", + following_url: + "https://api.github.com/users/bmsteven/following{/other_user}", + gists_url: "https://api.github.com/users/bmsteven/gists{/gist_id}", + gravatar_id: "", + html_url: "https://github.com/bmsteven", + id: 48621248, + login: "bmsteven", + name: "bmsteven", + node_id: "MDQ6VXNlcjQ4NjIxMjQ4", + organizations_url: "https://api.github.com/users/bmsteven/orgs", + received_events_url: + "https://api.github.com/users/bmsteven/received_events", + repos_url: "https://api.github.com/users/bmsteven/repos", + site_admin: false, + starred_url: + "https://api.github.com/users/bmsteven/starred{/owner}{/repo}", + subscriptions_url: "https://api.github.com/users/bmsteven/subscriptions", + type: "User", + url: "https://api.github.com/users/bmsteven", + }, + private: false, + pulls_url: "https://api.github.com/repos/bmsteven/demo/pulls{/number}", + pushed_at: 1650646867, + releases_url: "https://api.github.com/repos/bmsteven/demo/releases{/id}", + size: 169, + ssh_url: "git@github.com:bmsteven/demo.git", + stargazers: 0, + stargazers_count: 0, + stargazers_url: "https://api.github.com/repos/bmsteven/demo/stargazers", + statuses_url: "https://api.github.com/repos/bmsteven/demo/statuses/{sha}", + subscribers_url: "https://api.github.com/repos/bmsteven/demo/subscribers", + subscription_url: "https://api.github.com/repos/bmsteven/demo/subscription", + svn_url: "https://github.com/bmsteven/demo", + tags_url: "https://api.github.com/repos/bmsteven/demo/tags", + teams_url: "https://api.github.com/repos/bmsteven/demo/teams", + topics: [], + trees_url: "https://api.github.com/repos/bmsteven/demo/git/trees{/sha}", + updated_at: "2022-04-20T22:35:19Z", + url: "https://github.com/bmsteven/demo", + visibility: "public", + watchers: 0, + watchers_count: 0, + }, + sender: { + avatar_url: "https://avatars.githubusercontent.com/u/48621248?v=4", + events_url: "https://api.github.com/users/bmsteven/events{/privacy}", + followers_url: "https://api.github.com/users/bmsteven/followers", + following_url: + "https://api.github.com/users/bmsteven/following{/other_user}", + gists_url: "https://api.github.com/users/bmsteven/gists{/gist_id}", + gravatar_id: "", + html_url: "https://github.com/bmsteven", + id: 48621248, + login: "bmsteven", + node_id: "MDQ6VXNlcjQ4NjIxMjQ4", + organizations_url: "https://api.github.com/users/bmsteven/orgs", + received_events_url: + "https://api.github.com/users/bmsteven/received_events", + repos_url: "https://api.github.com/users/bmsteven/repos", + site_admin: false, + starred_url: "https://api.github.com/users/bmsteven/starred{/owner}{/repo}", + subscriptions_url: "https://api.github.com/users/bmsteven/subscriptions", + type: "User", + url: "https://api.github.com/users/bmsteven", + }, +}; diff --git a/src/develop_actions.js b/src/develop_actions.js index 956fa00..c4762c3 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -1,6 +1,7 @@ const axios = require("axios"); const github = require("@actions/github"); const core = require("@actions/core"); +// const response = require("../res"); const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN"); const octokit = github.getOctokit(GITHUB_TOKEN); @@ -9,7 +10,24 @@ const { context = {} } = github; const run = async () => { console.log(context.payload); console.log(GITHUB_TOKEN); - console.log("test actions"); + // console.log("test actions"); + try { + const branch_name = context.payload?.response?.head_commit?.message + ?.split("from")[1] + .split("\n")[0]; + + const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { + owner: "bmsteven", + repo: "demo", + title: "Amazing new feature", + body: "Please pull these awesome changes in!", + head: branch_name, + base: "staging", + }); + console.log("createPr", createPr?.data); + } catch (error) { + console.log("error"); + } }; run(); From 92ada48ef63afb49835efa8e4cbb90ecd9c83931 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:17:42 +0300 Subject: [PATCH 07/15] test creating pr to staging --- src/develop_actions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index c4762c3..8290b09 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -8,8 +8,8 @@ const octokit = github.getOctokit(GITHUB_TOKEN); const { context = {} } = github; const run = async () => { - console.log(context.payload); - console.log(GITHUB_TOKEN); + // console.log(context.payload); + // console.log(GITHUB_TOKEN); // console.log("test actions"); try { const branch_name = context.payload?.response?.head_commit?.message @@ -24,9 +24,9 @@ const run = async () => { head: branch_name, base: "staging", }); - console.log("createPr", createPr?.data); + console.log("createPr", createpr?.data); } catch (error) { - console.log("error"); + console.log("error", error?.message); } }; From 08f6d21e199e9dbbb52b88fd3e9ef2eb7828150f Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:20:27 +0300 Subject: [PATCH 08/15] test creating pr to staging --- src/develop_actions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/develop_actions.js b/src/develop_actions.js index 8290b09..6c9f6f6 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -16,6 +16,8 @@ const run = async () => { ?.split("from")[1] .split("\n")[0]; + console.log(branch_name); + const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { owner: "bmsteven", repo: "demo", From 741dbc5973a9960a192d795f635978927b8265d3 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:20:39 +0300 Subject: [PATCH 09/15] test creating pr to staging --- src/develop_actions.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 6c9f6f6..104e847 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -18,15 +18,15 @@ const run = async () => { console.log(branch_name); - const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { - owner: "bmsteven", - repo: "demo", - title: "Amazing new feature", - body: "Please pull these awesome changes in!", - head: branch_name, - base: "staging", - }); - console.log("createPr", createpr?.data); + // const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { + // owner: "bmsteven", + // repo: "demo", + // title: "Amazing new feature", + // body: "Please pull these awesome changes in!", + // head: branch_name, + // base: "staging", + // }); + // console.log("createPr", createpr?.data); } catch (error) { console.log("error", error?.message); } From 7ccaf52fb983a1cd93edf2eef0f24387662cdfdc Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:22:41 +0300 Subject: [PATCH 10/15] test creating pr to staging --- src/develop_actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 104e847..6cc8b91 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -12,7 +12,7 @@ const run = async () => { // console.log(GITHUB_TOKEN); // console.log("test actions"); try { - const branch_name = context.payload?.response?.head_commit?.message + const branch_name = context.payload?.head_commit?.message ?.split("from")[1] .split("\n")[0]; From 097c5eb89cd7d8a9f606a9e0efc6547d7672dbef Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:22:57 +0300 Subject: [PATCH 11/15] test creating pr to staging --- src/develop_actions.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 6cc8b91..7aca068 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -18,15 +18,15 @@ const run = async () => { console.log(branch_name); - // const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { - // owner: "bmsteven", - // repo: "demo", - // title: "Amazing new feature", - // body: "Please pull these awesome changes in!", - // head: branch_name, - // base: "staging", - // }); - // console.log("createPr", createpr?.data); + const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { + owner: "bmsteven", + repo: "demo", + title: "Amazing new feature", + body: "Please pull these awesome changes in!", + head: branch_name, + base: "staging", + }); + console.log("createPr", createpr?.data); } catch (error) { console.log("error", error?.message); } From 527561c9393216d4ca15ec88e400b16659d02cce Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:25:07 +0300 Subject: [PATCH 12/15] test creating pr to staging --- src/develop_actions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 7aca068..5c503e6 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -14,7 +14,8 @@ const run = async () => { try { const branch_name = context.payload?.head_commit?.message ?.split("from")[1] - .split("\n")[0]; + .split("\n")[0] + ?.split("/")[1]; console.log(branch_name); From 9c7928d59b69315811f29cb1793b94e10d173d92 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 20:50:55 +0300 Subject: [PATCH 13/15] test creating pr to staging --- src/develop_actions.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 5c503e6..6f2de29 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -1,32 +1,39 @@ const axios = require("axios"); const github = require("@actions/github"); const core = require("@actions/core"); -// const response = require("../res"); +const response = require("../res"); const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN"); const octokit = github.getOctokit(GITHUB_TOKEN); const { context = {} } = github; const run = async () => { - // console.log(context.payload); - // console.log(GITHUB_TOKEN); - // console.log("test actions"); try { const branch_name = context.payload?.head_commit?.message ?.split("from")[1] .split("\n")[0] - ?.split("/")[1]; + ?.split("/") + .slice(1) + .join("/"); - console.log(branch_name); + console.log("branch name", branch_name); + console.log("full name", context.payload?.full_name); + console.log("owner", context.payload?.owner?.login); + console.log("repo", context.payload?.repository?.name); - const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", { - owner: "bmsteven", - repo: "demo", - title: "Amazing new feature", - body: "Please pull these awesome changes in!", - head: branch_name, - base: "staging", - }); + // fetch and format commits + + const createpr = await octokit.request( + `POST /repos/${context.payload?.full_name}/pulls`, + { + owner: context.payload?.owner?.login, + repo: context.payload?.repository?.name, + title: branch_name, + body: "Please pull these awesome changes in!", + head: branch_name, + base: "staging", + } + ); console.log("createPr", createpr?.data); } catch (error) { console.log("error", error?.message); From f872f9e6f8adb191e1d6c608114bf01638735cfa Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 22:24:57 +0300 Subject: [PATCH 14/15] test formatting pr commits --- src/develop_actions.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 6f2de29..65b8abb 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -1,7 +1,7 @@ const axios = require("axios"); const github = require("@actions/github"); const core = require("@actions/core"); -const response = require("../res"); +// const response = require("../res"); const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN"); const octokit = github.getOctokit(GITHUB_TOKEN); @@ -21,7 +21,21 @@ const run = async () => { console.log("owner", context.payload?.owner?.login); console.log("repo", context.payload?.repository?.name); - // fetch and format commits + console.log("commits", context.payload?.commits); + let commits = ""; + + context.payload?.commits?.forEach((e, i) => { + if ( + !e.message.includes("Merge") && + !e.message.includes("Merged") && + !e.message.includes("skip") && + !e.message.includes("Skip") + ) + commits = + commits + i !== 0 ? "> " + e.message : "\n\n" + "> " + e.message; + }); + + console.log("formatted commits", commits); const createpr = await octokit.request( `POST /repos/${context.payload?.full_name}/pulls`, From 590590b5b470599bde9c8486f1da8ac3230bcfd4 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 22:25:42 +0300 Subject: [PATCH 15/15] passing commits in pr request body --- src/develop_actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 65b8abb..f75b47a 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -43,7 +43,7 @@ const run = async () => { owner: context.payload?.owner?.login, repo: context.payload?.repository?.name, title: branch_name, - body: "Please pull these awesome changes in!", + body: commits, head: branch_name, base: "staging", }