fix #33
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, pull_request] | |
| 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 (for push events) | |
| id: get_pr_number | |
| if: github.event_name == 'push' | |
| run: | | |
| PR_NUMBER=$(gh pr list --head "$GITHUB_REF_NAME" --json number -q '.[0].number' || echo "") | |
| echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set PR number variable (for all cases) | |
| id: set_vars | |
| run: | | |
| echo "pr_number=${{ github.event.pull_request.number || env.PR_NUMBER }}" >> $GITHUB_OUTPUT | |
| - name: Build cmk binary | |
| id: build_cmk | |
| run: go build -v -o cmk ./cmk.go | |
| - name: Rename binary | |
| run: | | |
| mv cmk cmk.linux.x86-64.pr${{ steps.set_vars.outputs.pr_number }} | |
| - name: Upload cmk binary | |
| uses: actions/upload-artifact@v4 | |
| if: steps.set_vars.outputs.pr_number != '' | |
| with: | |
| name: cmk.linux.x86-64.pr${{ steps.set_vars.outputs.pr_number }} | |
| path: cmk.linux.x86-64.pr${{ steps.set_vars.outputs.pr_number }} | |
| if-no-files-found: error | |
| - name: Create/update comment (final status) | |
| uses: peter-evans/create-or-update-comment@v4 | |
| if: steps.set_vars.outputs.pr_number != '' | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ steps.set_vars.outputs.pr_number }} | |
| body: | | |
| <!-- cmk-build-artifact-comment --> | |
| ${{ job.status == 'success' && '✅ Build complete' || '❌ Build failed' }} for PR #${{ steps.set_vars.outputs.pr_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 |