Skip to content

Commit

Permalink
feat(actions): add new build.yml for build the golang sample projects
Browse files Browse the repository at this point in the history
Signed-off-by: Rishav Mehra <rishavmehra61@gmail.com>
  • Loading branch information
rishavmehra committed Oct 3, 2024
1 parent 6786578 commit cbc12fa
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build Go Sample Projects

on:
push:
branches:
- master
- main
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.22'

- name: Build projects
run: |
#!/bin/bash
cd /home/runner/work/samples-go/samples-go
for dir in */; do
if [ -d "$dir" ] && [ -f "${dir}go.mod" ]; then
echo "Building project in $dir"
# Change to the project directory
cd "$dir" || continue
# Build the project
if go build -o app; then
echo "Successfully built $dir"
else
echo "Failed to build $dir" >&2
exit 1
fi
# Return to the base directory
cd ..
else
echo "Skipping $dir, no go.mod file found."
fi
done
echo "All projects processed."

0 comments on commit cbc12fa

Please sign in to comment.