Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/merge_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- 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: 🔀 Merge Pull Request
# uses: BaharaJr/merge-pr@0.0.1
# with:
# GITHUB_TOKEN: ${{ secrets.TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/npm-gulp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
run: npm install

- name: gulp
run: npm install -g gulp axios
run: npm install -g gulp axios @octokit/core

- name: notify
run: gulp createnotification --b ${{ secrets.SLACK_WEBHOOK_URL }}
# run: gulp createnotification --b ${{ secrets.SLACK_WEBHOOK_URL }}
run: gulp getpulls --b ${{ secrets.TOKEN }}

89 changes: 88 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const gulp = require("gulp");
const axios = require("axios");
const { Octokit } = require("@octokit/core");

gulp.task("createnotification", async () => {
const options = {
Expand Down Expand Up @@ -64,7 +65,6 @@ gulp.task("createnotification", async () => {
},
],
};

axios
.post(`${process.argv[4]}`, JSON.stringify(options))
.then((response) => {
Expand All @@ -76,3 +76,90 @@ gulp.task("createnotification", async () => {
reject(new Error("FAILED: Send slack webhook"));
});
});

gulp.task("getpulls", async () => {
try {
const octokit = new Octokit({ auth: process.argv[4] });
const pulls = await octokit.request("GET /repos/bmsteven/demo/pulls", {
owner: "bmsteven",
repo: "demo",
base: "staging",
});
console.log("pulls", pulls?.data);

const pull = await octokit.request("GET /repos/bmsteven/demo/pulls/16", {
owner: "bmsteven",
repo: "demo",
pull_number: "16",
});
console.log("pull", pull?.data);
// update pull request
// await octokit.request("PATCH /repos/{owner}/{repo}/pulls/{pull_number}", {
// owner: "OWNER",
// repo: "REPO",
// pull_number: "PULL_NUMBER",
// title: "new title",
// body: "updated body",
// state: "open",
// base: "master",
// });
// get pull request commits
const commits = await octokit.request(
"GET /repos/bmsteven/demo/pulls/16/commits",
{
owner: "bmsteven",
repo: "demo",
pull_number: "16",
}
);
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);
// merge pull request
const mergepr = await octokit.request(
"PUT /repos/bmsteven/demo/pulls/16/merge",
{
owner: "bmsteven",
repo: "demo",
pull_number: "16",
}
);
console.log("mergepr", mergepr?.data);
// create new pull request
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: "staging",
base: "master",
});
console.log("createPr", createPr?.data);
} catch (error) {
console.log(error?.message);
}
});

// scheduled
// on:
// schedule:
// - cron: '30 5 * * 1,3'
// - cron: '30 5 * * 2,4'

// jobs:
// test_schedule:
// runs-on: ubuntu-latest
// steps:
// - name: Not on Monday or Wednesday
// if: github.event.schedule != '30 5 * * 1,3'
// run: echo "This step will be skipped on Monday and Wednesday"
// - name: Every time
// run: echo "This step will always run"
Loading