From 4f749c5bb1df99a9f48a8786e711925ee57cdf55 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:20:30 +0300 Subject: [PATCH 01/12] change workflow Signed-off-by: Vasiliy Tolstov --- ...dependabot-automerge.yml => automerge.yml} | 8 ++---- .github/workflows/autoreview.yml | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) rename .github/workflows/{dependabot-automerge.yml => automerge.yml} (73%) create mode 100644 .github/workflows/autoreview.yml diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/automerge.yml similarity index 73% rename from .github/workflows/dependabot-automerge.yml rename to .github/workflows/automerge.yml index 12490d1..64e1b7c 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/automerge.yml @@ -11,18 +11,14 @@ permissions: jobs: dependabot: runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} + if: | + github.actor == 'dependabot[bot]' steps: - name: metadata id: metadata uses: dependabot/fetch-metadata@v1.3.0 with: github-token: "${{ secrets.TOKEN }}" - - name: approve - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.TOKEN}} - name: merge if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}} run: gh pr merge --auto --merge "$PR_URL" diff --git a/.github/workflows/autoreview.yml b/.github/workflows/autoreview.yml new file mode 100644 index 0000000..2b95906 --- /dev/null +++ b/.github/workflows/autoreview.yml @@ -0,0 +1,27 @@ +name: "autoreview" + +on: + pull_request_target: + types: [assigned, opened, synchronize, reopened] + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: | + github.actor == 'vtolstov' || + github.actor == 'dependabot[bot]' + steps: + - name: metadata + id: metadata + uses: dependabot/fetch-metadata@v1.3.0 + with: + github-token: "${{ secrets.TOKEN }}" + - name: approve + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.TOKEN}} From 1ee46a0aac54ed69da7aa1b872ccea3484621dae Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:25:01 +0300 Subject: [PATCH 02/12] update workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/autoreview.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/autoreview.yml b/.github/workflows/autoreview.yml index 2b95906..071176d 100644 --- a/.github/workflows/autoreview.yml +++ b/.github/workflows/autoreview.yml @@ -15,11 +15,6 @@ jobs: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' steps: - - name: metadata - id: metadata - uses: dependabot/fetch-metadata@v1.3.0 - with: - github-token: "${{ secrets.TOKEN }}" - name: approve run: gh pr review --approve "$PR_URL" env: From bce6f8c3e75dfe7844a0458a2a01fb437a9ccc77 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:32:28 +0300 Subject: [PATCH 03/12] fix workflows Signed-off-by: Vasiliy Tolstov --- .github/workflows/{autoreview.yml => autoapprove.yml} | 10 +++++----- .github/workflows/automerge.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) rename .github/workflows/{autoreview.yml => autoapprove.yml} (67%) diff --git a/.github/workflows/autoreview.yml b/.github/workflows/autoapprove.yml similarity index 67% rename from .github/workflows/autoreview.yml rename to .github/workflows/autoapprove.yml index 071176d..50ce9e0 100644 --- a/.github/workflows/autoreview.yml +++ b/.github/workflows/autoapprove.yml @@ -1,4 +1,4 @@ -name: "autoreview" +name: "autoapprove" on: pull_request_target: @@ -9,13 +9,13 @@ permissions: contents: write jobs: - dependabot: + autoapprove: runs-on: ubuntu-latest - if: | - github.actor == 'vtolstov' || - github.actor == 'dependabot[bot]' steps: - name: approve + uses: hmarr/auto-approve-action@v2 + if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' + id: approve run: gh pr review --approve "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 64e1b7c..2f12b4f 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -9,10 +9,9 @@ permissions: contents: write jobs: - dependabot: + automerge: runs-on: ubuntu-latest - if: | - github.actor == 'dependabot[bot]' + if: github.actor == 'dependabot[bot]' steps: - name: metadata id: metadata @@ -20,6 +19,7 @@ jobs: with: github-token: "${{ secrets.TOKEN }}" - name: merge + id: merge if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}} run: gh pr merge --auto --merge "$PR_URL" env: From fa9e204032c969caf51c7f9cc6419d35152bb8a1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:38:35 +0300 Subject: [PATCH 04/12] update Signed-off-by: Vasiliy Tolstov --- .github/workflows/automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 2f12b4f..b0c94b4 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -1,4 +1,4 @@ -name: "prautomerge" +name: "automerge" on: pull_request_target: From 2061b2dbb63c61765618b065ef74f8a1e05f4490 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:45:06 +0300 Subject: [PATCH 05/12] update worklow Signed-off-by: Vasiliy Tolstov --- .github/workflows/autoapprove.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml index 50ce9e0..3d8e3fe 100644 --- a/.github/workflows/autoapprove.yml +++ b/.github/workflows/autoapprove.yml @@ -16,7 +16,6 @@ jobs: uses: hmarr/auto-approve-action@v2 if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' id: approve - run: gh pr review --approve "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.TOKEN}} From 178d68aae946b07ad0c016e6681cbb8aedd3c9fb Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:46:00 +0300 Subject: [PATCH 06/12] add message metadata support Signed-off-by: Vasiliy Tolstov --- http.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/http.go b/http.go index 8e843df..b29468a 100644 --- a/http.go +++ b/http.go @@ -604,6 +604,8 @@ func (h *httpClient) Publish(ctx context.Context, p client.Message, opts ...clie } func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...client.PublishOption) error { + var body []byte + options := client.NewPublishOptions(opts...) // get proxy @@ -622,24 +624,22 @@ func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...c for _, p := range ps { md := metadata.Copy(omd) md[metadata.HeaderContentType] = p.ContentType() - md[metadata.HeaderTopic] = p.Topic() - - cf, err := h.newCodec(p.ContentType()) - if err != nil { - return errors.InternalServerError("go.micro.client", err.Error()) - } - - var body []byte // passed in raw data if d, ok := p.Payload().(*codec.Frame); ok { body = d.Data } else { - b := bytes.NewBuffer(nil) - if err := cf.Write(b, &codec.Message{Type: codec.Event}, p.Payload()); err != nil { + // use codec for payload + cf, err := h.newCodec(p.ContentType()) + if err != nil { return errors.InternalServerError("go.micro.client", err.Error()) } - body = b.Bytes() + // set the body + b, err := cf.Marshal(p.Payload()) + if err != nil { + return errors.InternalServerError("go.micro.client", err.Error()) + } + body = b } topic := p.Topic() @@ -647,6 +647,9 @@ func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...c topic = exchange } + for k, v := range p.Metadata() { + md.Set(k, v) + } md.Set(metadata.HeaderTopic, topic) msgs = append(msgs, &broker.Message{Header: md, Body: body}) } From 2e218748e860092013882b20e8aa95e0a87f5e0c Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:47:38 +0300 Subject: [PATCH 07/12] fix workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/autoapprove.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml index 3d8e3fe..3e0ffed 100644 --- a/.github/workflows/autoapprove.yml +++ b/.github/workflows/autoapprove.yml @@ -16,6 +16,5 @@ jobs: uses: hmarr/auto-approve-action@v2 if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' id: approve - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.TOKEN}} + with: + github-token: ${{secrets.TOKEN}} \ No newline at end of file From 93344a3f7bb89b16b5df000a683b73118b7154a8 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:49:01 +0300 Subject: [PATCH 08/12] fix workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/autoapprove.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml index 3d8e3fe..3e0ffed 100644 --- a/.github/workflows/autoapprove.yml +++ b/.github/workflows/autoapprove.yml @@ -16,6 +16,5 @@ jobs: uses: hmarr/auto-approve-action@v2 if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' id: approve - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.TOKEN}} + with: + github-token: ${{secrets.TOKEN}} \ No newline at end of file From 5d3cbfc7d3ec036c7a322a25e4d1a92dadfbb201 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:54:28 +0300 Subject: [PATCH 09/12] fix workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/autoapprove.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml index 3e0ffed..ebe28c9 100644 --- a/.github/workflows/autoapprove.yml +++ b/.github/workflows/autoapprove.yml @@ -17,4 +17,4 @@ jobs: if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]' id: approve with: - github-token: ${{secrets.TOKEN}} \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From db9c686306fac8f315eb54c3e1435e77a936dcc9 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 18:57:54 +0300 Subject: [PATCH 10/12] fix workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/automerge.yml | 7 +----- .github/workflows/dependabot-automerge.yml | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/dependabot-automerge.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index b0c94b4..0880aab 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -11,13 +11,8 @@ permissions: jobs: automerge: runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' + if: github.actor == 'vtolstov' steps: - - name: metadata - id: metadata - uses: dependabot/fetch-metadata@v1.3.0 - with: - github-token: "${{ secrets.TOKEN }}" - name: merge id: merge if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}} diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..b0c94b4 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,27 @@ +name: "automerge" + +on: + pull_request_target: + types: [assigned, opened, synchronize, reopened] + +permissions: + pull-requests: write + contents: write + +jobs: + automerge: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: metadata + id: metadata + uses: dependabot/fetch-metadata@v1.3.0 + with: + github-token: "${{ secrets.TOKEN }}" + - name: merge + id: merge + if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.TOKEN}} From 91cf06abbd35a7e4288f8a4b4f90c1517da6cf07 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 19:01:13 +0300 Subject: [PATCH 11/12] fix workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/dependabot-automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index b0c94b4..3681028 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -1,4 +1,4 @@ -name: "automerge" +name: "dependabot-automerge" on: pull_request_target: From e9be505c59e1b2c2f5ed7473b75facfd06d51348 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 5 Mar 2022 19:02:47 +0300 Subject: [PATCH 12/12] fix workflow Signed-off-by: Vasiliy Tolstov --- .github/workflows/automerge.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 0880aab..5ff3f69 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -15,7 +15,6 @@ jobs: steps: - name: merge id: merge - if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}} run: gh pr merge --auto --merge "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}}