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 | ||
|
Check failure on line 1 in .github/workflows/build-pr-cmk.yml
|
||
| 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: Get PR number from Push event | ||
| id: get_pr_number | ||
| if: ${{ github.event_name == 'push' }} # Only run this on push events | ||
| run: | | ||
| echo "::set-output name=pr_number::$(gh pr view --json number -q .number || echo "")" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Create placeholder PR comment | ||
| id: create_comment | ||
| if: ${{ github.event_name == 'pull_request' || || steps.get_pr_number.outputs.pr_number != '' }} | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| issue-number: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || steps.get_pr_number.outputs.pr_number }} | ||
| body: | | ||
| <!-- cmk-build-artifact-comment --> | ||
| ⏳ Build initiated for PR #${{ github.event.pull_request.number }}. Status will be updated here. | ||
| edit-mode: replace # Creates a new comment if none exists with this marker | ||
| - name: Build cmk binary | ||
| id: build_cmk | ||
| run: go build -v -o cmk ./cmk.go | ||
| - name: Rename binary with platform and PR number | ||
| if: ${{ success() }} # Only rename if the build was successful | ||
| run: | | ||
| pr_number=${{ github.event.pull_request.number }} | ||
| mv cmk cmk.linux.x86-64.pr${pr_number} | ||
| - name: Upload cmk binary | ||
| if: ${{ success() }} # Only upload if the build was successful | ||
| 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: Update PR comment (Final Status) | ||
| if: ${{ github.event_name == 'pull_request' || || steps.get_pr_number.outputs.pr_number != '' }} | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| issue-number: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || steps.get_pr_number.outputs.pr_number }} | ||
| 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 binary](https://github.com/{0}/actions/runs/{1})', github.repository, github.run_id) || format('See the [workflow run](https://github.com/{0}/actions/runs/{1}) for details.', github.repository, github.run_id) }} | ||
| edit-mode: replace # Replaces the content of the identified comment | ||