Add gh action workflow for ci test
Change-Id: I4a4dc1ae8f36c6a23a6b458a656e69ff24a02bde
diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml
new file mode 100644
index 0000000..63e4e4d
--- /dev/null
+++ b/.github/workflows/ci_test.yml
@@ -0,0 +1,18 @@
+name: CI Test
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v1
+ with:
+ java-version: 1.8
+
+ - name: Build and install
+ run: mvn install
diff --git a/.github/workflows/re-run-pull-request-github-actions.yml b/.github/workflows/re-run-pull-request-github-actions.yml
new file mode 100644
index 0000000..4a2fddf
--- /dev/null
+++ b/.github/workflows/re-run-pull-request-github-actions.yml
@@ -0,0 +1,65 @@
+name: Re-run CI tests on open PRs
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ re-run-github-actions:
+ runs-on: ubuntu-latest
+ steps:
+ - name: (GET-&-PUT Github API) Push empty commit to PR branch
+ uses: actions/github-script@0.2.0
+ with:
+ github-token: ${{secrets.PAT}}
+ script: |
+ const owner = context.repo.owner;
+ const repo = context.repo.repo;
+ const {data: pullRequests} = await github.pulls.list({
+ owner,
+ repo,
+ base: "master",
+ state: "open",
+ });
+
+ for (pr of pullRequests) {
+ try {
+ let pullReq = {};
+ while (pullReq.mergeable === undefined || pullReq.mergeable === null) {
+ pullReq = (
+ await github.pulls.get({
+ owner,
+ repo,
+ pull_number: pr.number,
+ })
+ ).data;
+ }
+ if(pullReq.mergeable === false) continue;
+
+ const {data: commitData} = await github.repos.getCommit({
+ owner,
+ repo,
+ ref: pullReq.head.sha,
+ });
+
+ const {data: createdCommit} = await github.git.createCommit({
+ owner,
+ repo,
+ message: "trigger github actions",
+ tree: commitData.commit.tree.sha,
+ parents: [commitData.sha],
+ commiter: context.payload.pusher,
+ author: context.payload.pusher,
+ });
+
+ await github.git.updateRef({
+ owner,
+ repo,
+ ref: `heads/${pr.head.ref}`,
+ sha: createdCommit.sha,
+ });
+ } catch (err) {
+ console.log(err);
+ }
+ }