test #21
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: | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| paths: | |
| - '**.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build: | |
| if: ${{ github.repository == 'shwstppr/cloudstack-cloudmonkey' }} | |
| 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_step # Add an ID to the build step to check its status | |
| run: go build -v -o cmk ./cmk.go | |
| - name: Rename binary with platform and PR number | |
| run: | | |
| pr_number=${{ github.event.pull_request.number }} | |
| mv cmk cmk.linux.x86-64.pr${pr_number} | |
| - name: Upload cmk binary | |
| uses: actions/upload-artifact@v4 | |
| 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: Create or update PR comment (Success) | |
| if: ${{ success() && github.event_name == 'pull_request' }} # Only run on PR event and if build succeeds | |
| uses: peter-evans/create-or-update-comment@v4 | |
| id: pr_comment # Give this step an ID to access its outputs | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| <!-- cmk-build-artifact --> | |
| ✅ Build complete for PR #${{ github.event.pull_request.number }} | |
| 🔗 [Download the cmk binary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| edit-mode: replace | |
| - name: Update PR comment (Failure) | |
| if: ${{ failure() && github.event_name == 'pull_request' }} # Only run on PR event and if build fails | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| <!-- cmk-build-artifact --> | |
| ❌ Build failed for PR #${{ github.event.pull_request.number }} | |
| See the [workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. | |
| edit-mode: replace # Replaces the previous comment | |