Skip to content

feat: Implement orb worker backend #3

feat: Implement orb worker backend

feat: Implement orb worker backend #3

Workflow file for this run

name: Orb Agent - build
on:
push:
branches:
- "!release"
- "develop"
paths:
- "agent/**"
- "cmd/**"
- "!agent/docker/**"
pull_request:
paths:
- "agent/**"
- "cmd/**"
- "!agent/docker/**"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
env:
GO_VERSION: '1.23'
permissions:
contents: write
pull-requests: write
jobs:
go-test:
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: .
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23.x'
check-latest: true
- name: Run go build
run: go build ./...
- name: Install additional dependencies
run: |
go install github.com/mfridman/[email protected]
sudo apt-get -y install nmap
- name: Run go test
id: go-test
run: |
make test-coverage
echo 'coverage-report<<EOF' >> $GITHUB_OUTPUT
cat .coverage/test-report.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "coverage-total=$(cat .coverage/coverage.txt)" >> $GITHUB_OUTPUT
- name: Output Result
if: always()
run: cat .coverage/test-report.md
- name: Find comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e #v3.1.0
id: existing-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Go test coverage
- name: Post comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 #v4.0.0
with:
comment-id: ${{ steps.existing-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Go test coverage
${{ steps.go-test.outputs.coverage-report }}
Total coverage: ${{ steps.go-test.outputs.coverage-total }}%
edit-mode: replace
build-and-push:
needs: go-test
runs-on: ubuntu-latest
if: success() && github.ref == 'refs/heads/develop'
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf #v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 #v3.8.0
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set build info
run: |
echo ${GITHUB_SHA::7} > ./agent/version/BUILD_COMMIT.txt
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.tag_name')
echo $LATEST_RELEASE > ./agent/version/BUILD_VERSION.txt
- name: Build image and push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 #v6.10.0
with:
context: .
file: agent/docker/Dockerfile
platforms: linux/amd64, linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: netboxlabs/orb-agent:develop
build-args: |
GO_VERSION=${{ env.GO_VERSION }}