Build cmk binaries on PR #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build cmk on PR | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Build cmk binary | |
| id: build_cmk | |
| run: go build -v -o cmk ./cmk.go | |
| continue-on-error: true | |
| - name: Rename binary | |
| if: success() | |
| run: | | |
| mv cmk cmk.linux.x86-64.pr${{ github.event.pull_request.number }} | |
| - name: Upload cmk binary | |
| uses: actions/upload-artifact@v4 | |
| if: success() | |
| with: | |
| name: cmk.linux.x86-64.pr${{ github.event.pull_request.number }} | |
| path: cmk.linux.x86-64.pr${{ github.event.pull_request.number }} | |
| if-no-files-found: error | |
| - name: Find existing PR comment | |
| id: find_comment | |
| if: always() | |
| uses: peter-evans/find-comment@v3 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: '<!-- cmk-build-artifact-comment -->' | |
| - name: Create/update comment | |
| if: always() | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
| body: | | |
| <!-- cmk-build-artifact-comment --> | |
| ${{ job.status == 'success' && '✅ Build complete' || '❌ Build failed' }} for PR #${{ github.event.pull_request.number }}. | |
| ${{ job.status == 'success' | |
| && format('🔗 [Download the cmk.linux.x86-64.pr{2} binary](https://github.com/{0}/actions/runs/{1})', github.repository, github.run_id, github.event.pull_request.number) | |
| || format('See the [workflow run](https://github.com/{0}/actions/runs/{1}) for details.', github.repository, github.run_id) }} | |
| edit-mode: replace |