generated from keploy/template
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): add new build.yml for build the golang sample projects
Signed-off-by: Rishav Mehra <rishavmehra61@gmail.com>
- Loading branch information
1 parent
6786578
commit cbc12fa
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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." |