From 6db0465ea505914b1292ada098f61ef2949ceef4 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Wed, 15 Sep 2021 17:57:49 +0200 Subject: [PATCH 1/6] [github] ADD ci-build workflow --- .github/workflows/ci-build.yml | 118 +++++++++++++++++++++++++++++++++ .github/workflows/macos.yml | 5 +- .github/workflows/ubuntu.yml | 5 +- 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci-build.yml diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 000000000..a7e92c250 --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,118 @@ +name: ci-build + +on: + workflow_dispatch: + issue_comment: + types: [created] + +jobs: + run: + runs-on: ubuntu-latest + + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + ISSUE_BODY: "${{ github.event.issue.body }}" + + steps: + - name: Parse comment + if: github.event.issue.pull_request + uses: khan/pull-request-comment-trigger@1.0.0 + id: check + with: + trigger: '[ci-build]' + + - name: Debug logs + if: steps.check.outputs.triggered == 'true' + run: | + echo "Trigger key detected." + echo "----------------------------------" + echo " github.event.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" + echo " github.event.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" + echo " github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" + echo " github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" + echo " github.event.pull_request.number = ${{ github.event.pull_request.number }}" + echo " github.event.pull_request.merge_commit_sha = ${{ github.event.pull_request.merge_commit_sha }}" + echo "----------------------------------" + echo " github.event.issue.number = ${{ github.event.issue.number }}" + echo " github.event.issue.pull_request = ${{ github.event.issue.pull_request }}" + echo " github.event.issue.pull_request.merge_commit_sha = ${{ github.event.issue.pull_request.merge_commit_sha }}" + echo " github.event.issue.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" + echo " github.event.issue.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" + echo " github.event.issue.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" + echo " github.event.issue.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" + echo " github.event.issue.pull_request.number = ${{ github.event.pull_request.number }}" + echo "----------------------------------" + echo " github.event.number = ${{ github.event.number }}" + echo " GITHUB_SHA = $GITHUB_SHA" + echo " GITHUB_REF = $GITHUB_REF" + echo " GITHUB_HEAD_REF = $GITHUB_HEAD_REF" + echo " GITHUB_BASE_REF = $GITHUB_BASE_REF" + echo "----------------------------------" + echo "github.event" + echo "${{ toJSON(github.event) }}" + echo "----------------------------------" + + - name: Trigger PR workflows + if: steps.check.outputs.triggered == 'true' + run: | + echo "-----------" + body="$(echo "$ISSUE_BODY" | sed ':a;N;$!ba;s/\r/\\r/g;s/\n/\\n/g;')" + echo "body = $body" + separator='\n' + if echo "$body" | grep -q '\n:rocket:$'; then + separator=' ' + fi + echo "-----------" + curl \ + -H "Authorization: token ${{ secrets.SOFA_REPO_WRITE_TOKEN }}" \ + -X PATCH \ + -d "{\"body\":\"$body$separator:rocket:\"}" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} + + + #- name: update-pull-request + # if: steps.check.outputs.triggered == 'true' + # uses: tzkhan/pr-update-action@v2 + # with: + # repo-token: "${{ secrets.GITHUB_TOKEN }}" + # base-branch-regex: '[a-z\d-_.\\/]+' + # body-update-action: 'suffix' + # body-newline-count: 1 + # body-template: "[ci-build] triggered." + + #- name: Clean assignees + # if: github.event.assignee.login == 'sofabot' + # run: | + # echo "Removing sofabot from assignees" + # echo "-------------" + # git show-ref + # echo "-------------" + # curl --silent \ + # -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + # -X DELETE \ + # -d '{"assignees":["sofabot"]}' \ + # https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/assignees + + #- name: Trigger workflow "Ubuntu CI" + # if: github.event.assignee.login == 'sofabot' + # run: | + # curl --silent \ + # -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + # -X POST \ + # -d '{"ref":"'$GITHUB_REF'"}' \ + # https://api.github.com/repos/${{ github.repository }}/actions/workflows/ubuntu.yml/dispatches + + #- name: Trigger workflow "Ubuntu CI" + # if: github.event.assignee.login == 'sofabot' + # uses: benc-uk/workflow-dispatch@v1 + # with: + # workflow: "Ubuntu CI" + # token: ${{ secrets.SOFA_REPO_WRITE_TOKEN }} + + #- name: Trigger workflow "MacOS CI" + # if: steps.check.outputs.triggered == 'true' + # uses: benc-uk/workflow-dispatch@v1 + # with: + # workflow: "MacOS CI" + # token: ${{ secrets.SOFA_REPO_WRITE_TOKEN }} + # ref: 'refs/pull/${{ github.event.issue.number }}/merge' diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 3a30a7d22..eaaf914bf 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,6 +1,9 @@ name: MacOS CI -on: [workflow_dispatch, pull_request] +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, edited] jobs: build: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6c84b8fd2..b9f595ecc 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,6 +1,9 @@ name: Ubuntu CI -on: [workflow_dispatch, pull_request] +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, edited] jobs: build: From c294d88772cbd573569f3c53d0540507fa789872 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Fri, 17 Sep 2021 11:53:10 +0200 Subject: [PATCH 2/6] [github] ADD ci-build workflow (2) --- .github/workflows/ci-build.yml | 66 ++++++++++++++++------------------ 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index a7e92c250..943a53160 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -21,36 +21,36 @@ jobs: with: trigger: '[ci-build]' - - name: Debug logs - if: steps.check.outputs.triggered == 'true' - run: | - echo "Trigger key detected." - echo "----------------------------------" - echo " github.event.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" - echo " github.event.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" - echo " github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" - echo " github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" - echo " github.event.pull_request.number = ${{ github.event.pull_request.number }}" - echo " github.event.pull_request.merge_commit_sha = ${{ github.event.pull_request.merge_commit_sha }}" - echo "----------------------------------" - echo " github.event.issue.number = ${{ github.event.issue.number }}" - echo " github.event.issue.pull_request = ${{ github.event.issue.pull_request }}" - echo " github.event.issue.pull_request.merge_commit_sha = ${{ github.event.issue.pull_request.merge_commit_sha }}" - echo " github.event.issue.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" - echo " github.event.issue.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" - echo " github.event.issue.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" - echo " github.event.issue.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" - echo " github.event.issue.pull_request.number = ${{ github.event.pull_request.number }}" - echo "----------------------------------" - echo " github.event.number = ${{ github.event.number }}" - echo " GITHUB_SHA = $GITHUB_SHA" - echo " GITHUB_REF = $GITHUB_REF" - echo " GITHUB_HEAD_REF = $GITHUB_HEAD_REF" - echo " GITHUB_BASE_REF = $GITHUB_BASE_REF" - echo "----------------------------------" - echo "github.event" - echo "${{ toJSON(github.event) }}" - echo "----------------------------------" + #- name: Debug logs + # if: steps.check.outputs.triggered == 'true' + # run: | + # echo "Trigger key detected." + # echo "----------------------------------" + # echo " github.event.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" + # echo " github.event.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" + # echo " github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" + # echo " github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" + # echo " github.event.pull_request.number = ${{ github.event.pull_request.number }}" + # echo " github.event.pull_request.merge_commit_sha = ${{ github.event.pull_request.merge_commit_sha }}" + # echo "----------------------------------" + # echo " github.event.issue.number = ${{ github.event.issue.number }}" + # echo " github.event.issue.pull_request = ${{ github.event.issue.pull_request }}" + # echo " github.event.issue.pull_request.merge_commit_sha = ${{ github.event.issue.pull_request.merge_commit_sha }}" + # echo " github.event.issue.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" + # echo " github.event.issue.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" + # echo " github.event.issue.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" + # echo " github.event.issue.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" + # echo " github.event.issue.pull_request.number = ${{ github.event.pull_request.number }}" + # echo "----------------------------------" + # echo " github.event.number = ${{ github.event.number }}" + # echo " GITHUB_SHA = $GITHUB_SHA" + # echo " GITHUB_REF = $GITHUB_REF" + # echo " GITHUB_HEAD_REF = $GITHUB_HEAD_REF" + # echo " GITHUB_BASE_REF = $GITHUB_BASE_REF" + # echo "----------------------------------" + # echo "github.event" + # echo "${{ toJSON(github.event) }}" + # echo "----------------------------------" - name: Trigger PR workflows if: steps.check.outputs.triggered == 'true' @@ -58,15 +58,11 @@ jobs: echo "-----------" body="$(echo "$ISSUE_BODY" | sed ':a;N;$!ba;s/\r/\\r/g;s/\n/\\n/g;')" echo "body = $body" - separator='\n' - if echo "$body" | grep -q '\n:rocket:$'; then - separator=' ' - fi echo "-----------" curl \ -H "Authorization: token ${{ secrets.SOFA_REPO_WRITE_TOKEN }}" \ -X PATCH \ - -d "{\"body\":\"$body$separator:rocket:\"}" \ + -d "{\"body\":\"$body\n[]()\"}" \ https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} From 4b024688ee793b40b80ebdcd1d5daddee3a7c9d5 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Fri, 17 Sep 2021 12:06:06 +0200 Subject: [PATCH 3/6] [github] ADD ci-build workflow (3) --- .github/workflows/ci-build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 943a53160..8d2c8d8a8 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -58,11 +58,16 @@ jobs: echo "-----------" body="$(echo "$ISSUE_BODY" | sed ':a;N;$!ba;s/\r/\\r/g;s/\n/\\n/g;')" echo "body = $body" + suffix='\n[]()' + if echo "$body" | grep -q '\\n\[\]()$'; then + body="$(echo "$body" | sed 's:\\n\[\]()$::g;')" + suffix='' + fi echo "-----------" curl \ -H "Authorization: token ${{ secrets.SOFA_REPO_WRITE_TOKEN }}" \ -X PATCH \ - -d "{\"body\":\"$body\n[]()\"}" \ + -d "{\"body\":\"$body$suffix\"}" \ https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} From 8c9f349cb66c93c3026c64dbf261a3711cf74385 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Fri, 17 Sep 2021 12:19:03 +0200 Subject: [PATCH 4/6] [github] CLEAN ci-build workflow --- .github/workflows/ci-build.yml | 79 ---------------------------------- 1 file changed, 79 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 8d2c8d8a8..c131efa2b 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -21,37 +21,6 @@ jobs: with: trigger: '[ci-build]' - #- name: Debug logs - # if: steps.check.outputs.triggered == 'true' - # run: | - # echo "Trigger key detected." - # echo "----------------------------------" - # echo " github.event.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" - # echo " github.event.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" - # echo " github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" - # echo " github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" - # echo " github.event.pull_request.number = ${{ github.event.pull_request.number }}" - # echo " github.event.pull_request.merge_commit_sha = ${{ github.event.pull_request.merge_commit_sha }}" - # echo "----------------------------------" - # echo " github.event.issue.number = ${{ github.event.issue.number }}" - # echo " github.event.issue.pull_request = ${{ github.event.issue.pull_request }}" - # echo " github.event.issue.pull_request.merge_commit_sha = ${{ github.event.issue.pull_request.merge_commit_sha }}" - # echo " github.event.issue.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}" - # echo " github.event.issue.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}" - # echo " github.event.issue.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}" - # echo " github.event.issue.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" - # echo " github.event.issue.pull_request.number = ${{ github.event.pull_request.number }}" - # echo "----------------------------------" - # echo " github.event.number = ${{ github.event.number }}" - # echo " GITHUB_SHA = $GITHUB_SHA" - # echo " GITHUB_REF = $GITHUB_REF" - # echo " GITHUB_HEAD_REF = $GITHUB_HEAD_REF" - # echo " GITHUB_BASE_REF = $GITHUB_BASE_REF" - # echo "----------------------------------" - # echo "github.event" - # echo "${{ toJSON(github.event) }}" - # echo "----------------------------------" - - name: Trigger PR workflows if: steps.check.outputs.triggered == 'true' run: | @@ -69,51 +38,3 @@ jobs: -X PATCH \ -d "{\"body\":\"$body$suffix\"}" \ https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} - - - #- name: update-pull-request - # if: steps.check.outputs.triggered == 'true' - # uses: tzkhan/pr-update-action@v2 - # with: - # repo-token: "${{ secrets.GITHUB_TOKEN }}" - # base-branch-regex: '[a-z\d-_.\\/]+' - # body-update-action: 'suffix' - # body-newline-count: 1 - # body-template: "[ci-build] triggered." - - #- name: Clean assignees - # if: github.event.assignee.login == 'sofabot' - # run: | - # echo "Removing sofabot from assignees" - # echo "-------------" - # git show-ref - # echo "-------------" - # curl --silent \ - # -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - # -X DELETE \ - # -d '{"assignees":["sofabot"]}' \ - # https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/assignees - - #- name: Trigger workflow "Ubuntu CI" - # if: github.event.assignee.login == 'sofabot' - # run: | - # curl --silent \ - # -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - # -X POST \ - # -d '{"ref":"'$GITHUB_REF'"}' \ - # https://api.github.com/repos/${{ github.repository }}/actions/workflows/ubuntu.yml/dispatches - - #- name: Trigger workflow "Ubuntu CI" - # if: github.event.assignee.login == 'sofabot' - # uses: benc-uk/workflow-dispatch@v1 - # with: - # workflow: "Ubuntu CI" - # token: ${{ secrets.SOFA_REPO_WRITE_TOKEN }} - - #- name: Trigger workflow "MacOS CI" - # if: steps.check.outputs.triggered == 'true' - # uses: benc-uk/workflow-dispatch@v1 - # with: - # workflow: "MacOS CI" - # token: ${{ secrets.SOFA_REPO_WRITE_TOKEN }} - # ref: 'refs/pull/${{ github.event.issue.number }}/merge' From af96eef19c0a6571cf7e18780282df55753f0ba0 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Fri, 17 Sep 2021 12:30:14 +0200 Subject: [PATCH 5/6] [github] CLEAN ci-build workflow (2) --- .github/workflows/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index c131efa2b..bf6650fa1 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -25,7 +25,7 @@ jobs: if: steps.check.outputs.triggered == 'true' run: | echo "-----------" - body="$(echo "$ISSUE_BODY" | sed ':a;N;$!ba;s/\r/\\r/g;s/\n/\\n/g;')" + body="$(echo "$ISSUE_BODY" | sed ':a;N;$!ba;s:\r:\\r:g;s:\n:\\n:g;')" echo "body = $body" suffix='\n[]()' if echo "$body" | grep -q '\\n\[\]()$'; then From b42cad910f6fb4aa8f75698480c62a27575b20a1 Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Fri, 17 Sep 2021 16:23:05 +0200 Subject: [PATCH 6/6] Update ci-build.yml --- .github/workflows/ci-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index bf6650fa1..8a6d2fcc3 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -20,6 +20,7 @@ jobs: id: check with: trigger: '[ci-build]' + reaction: rocket - name: Trigger PR workflows if: steps.check.outputs.triggered == 'true'