Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ protobuf
.gitmodules
Makefile
README.md
config/config.yaml
.github
.golanci.yml
LICENSE

# Test binary, built with `go test -c`
*.test
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Test, Release, Push

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test-healthz:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24.2'

- name: Build API Gateway
run: go build -o gateway .

- name: Run API Gateway in background
run: |
./gateway &
sleep 2

- name: Check /healthz endpoint
run: |
curl -f http://localhost:8000/healthz

release:
needs: test-healthz
runs-on: ubuntu-latest
permissions:
contents: write

outputs:
tag: ${{ steps.get_tag.outputs.tag }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run go-semantic-release
uses: go-semantic-release/action@v1
with:
hooks: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get latest tag or fallback
id: get_tag
run: |
TAG=$(git tag --sort=-creatordate | tail -n 1)
if [ -z "$TAG" ]; then
TAG="v1.0.0"
echo "::notice ::No tag found, defaulting to $TAG"
fi
echo "tag=$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Create GitHub Release if not exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_tag.outputs.tag }}
run: |
if gh release view "$VERSION" >/dev/null 2>&1; then
echo "Release $VERSION already exists, skipping creation."
else
gh release create "$VERSION" --generate-notes
fi

docker-push:
needs: release
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.QUIZWARS_DOCKER_USERNAME }}
password: ${{ secrets.QUIZWARS_DOCKER_PASSWORD }}

- name: Build & Push Docker image
run: |
TAG=${{ needs.release.outputs.tag }}
if [ -z "$TAG" ]; then
echo "No tag available for Docker image. Skipping push."
exit 0
fi
IMAGE=davidmovas/quizwars-api-gateway
docker build -t $IMAGE:$TAG .
docker tag $IMAGE:$TAG $IMAGE:latest
docker push $IMAGE:$TAG
docker push $IMAGE:latest
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*.so
*.dylib
.idea
gen

# Test binary, built with `go test -c`
*.test
Expand Down
Loading
Loading