From 78310a9f7264ecc595eb58e0901a4f277c9bc21e Mon Sep 17 00:00:00 2001 From: Henadzi Siardziukou Date: Thu, 25 Nov 2021 14:51:35 +0300 Subject: [PATCH 1/4] Added workflow file for builds with macos --- .github/workflows/macos-build.yml | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/macos-build.yml diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml new file mode 100644 index 00000000000..b3c7fca034d --- /dev/null +++ b/.github/workflows/macos-build.yml @@ -0,0 +1,73 @@ +name: build + +env: + GOPATH: /home/runner/work/gotest/gotest + GO111MODULE: off + REPO_PATH: src/gotest + MACOS_GOPATH: /Users/runner/work/gotest/gotest + GITHUB_TOKEN: ${{ github.token }} + +on: + workflow_dispatch: + inputs: + id: + description: 'Run ID' + required: true + runner: + description: 'Github actions runner' + required: true + default: 'macos-latest' + path: + description: 'Directory where to run command' + required: false + default: '' + pr: + description: 'Pull request id' + required: false + default: '' + go_version: + description: 'Go version' + required: false + default: '1.17' + command: + description: 'Command to run' + required: true + default: '' +jobs: + build: + runs-on: ${{ github.event.inputs.runner }} + steps: + - name: ${{ format('Run ID {0}', github.event.inputs.id) }} + run: echo Run ID ${{github.event.inputs.id}} + - name: Set environment for macos + if: ${{ contains(github.event.inputs.runner, 'macos') }} + run: | + echo Changed GOPATH to ${{ env.MACOS_GOPATH }} + echo "GOPATH="${{ env.MACOS_GOPATH }} >> $GITHUB_ENV + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ github.event.inputs.go_version }} + - name: Install dependencies + run: go get -u github.com/magefile/mage + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ env.GITHUB_REF }} + path: ${{ env.REPO_PATH }} + - name: Checkout and merge PR + if: ${{ github.event.inputs.pr }} + run: | + set -x + cd ${{ env.GOPATH }}/${{ env.REPO_PATH }} + git config --global user.email "user@example.com" + git config --global user.name "user" + git fetch origin pull/${{ github.event.inputs.pr }}/head:${{ github.event.inputs.id }} + git checkout ${{ github.event.inputs.id }} + git checkout $GITHUB_REF_NAME + git merge --no-ff ${{ github.event.inputs.id }} + - name: Run command + run: | + set -x + cd ${{ env.GOPATH }}/${{ env.REPO_PATH }}/${{ github.event.inputs.path }} + ${{ github.event.inputs.command }} From 86f43f553aa89185f50c6bb19a08ef13f55b8cb3 Mon Sep 17 00:00:00 2001 From: Henadzi Siardziukou Date: Thu, 25 Nov 2021 15:15:00 +0300 Subject: [PATCH 2/4] changed runner parameter to optional --- .github/workflows/macos-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index b3c7fca034d..eab20e98d7e 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -15,7 +15,7 @@ on: required: true runner: description: 'Github actions runner' - required: true + required: false default: 'macos-latest' path: description: 'Directory where to run command' From 806b54ee1e75b5b640bba0e1706589f9b567f5c7 Mon Sep 17 00:00:00 2001 From: Henadzi Siardziukou Date: Thu, 25 Nov 2021 19:03:14 +0300 Subject: [PATCH 3/4] renamed workflow and fixed pathes --- .github/workflows/macos-build.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index eab20e98d7e..6f392dff9e4 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -1,12 +1,9 @@ -name: build - +name: macos-build env: - GOPATH: /home/runner/work/gotest/gotest - GO111MODULE: off - REPO_PATH: src/gotest - MACOS_GOPATH: /Users/runner/work/gotest/gotest + GOPATH: /home/runner/work/beats/beats + REPO_PATH: src/beats + MACOS_GOPATH: /Users/runner/work/beats/beats GITHUB_TOKEN: ${{ github.token }} - on: workflow_dispatch: inputs: From 574afc40005c4dc4d7dffc18649003ac8a1491ff Mon Sep 17 00:00:00 2001 From: Henadzi Siardziukou Date: Thu, 25 Nov 2021 19:16:15 +0300 Subject: [PATCH 4/4] added GO111MODULE=off --- .github/workflows/macos-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index 6f392dff9e4..1b45fecd271 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -1,6 +1,7 @@ name: macos-build env: GOPATH: /home/runner/work/beats/beats + GO111MODULE: off REPO_PATH: src/beats MACOS_GOPATH: /Users/runner/work/beats/beats GITHUB_TOKEN: ${{ github.token }}