refactor: replace os.Getenv calls with viper configuration #107
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, Test and Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - v1 | |
| pull_request: | |
| branches: | |
| - main | |
| - v1 # Also run on PRs targeting v1 | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.4' # Make sure this matches go.mod | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Build | |
| run: | | |
| make build | |
| test: | |
| name: Test and Coverage | |
| runs-on: ubuntu-latest | |
| needs: build # Ensure build is successful before testing | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.4' | |
| - name: Run Test | |
| run: go test `go list ./... | grep -v /gen/ | grep -v /cmd/ | grep -v /helm/` -coverprofile=coverage.txt | |
| - name: Upload results to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| docker_build: | |
| name: Docker Build | |
| runs-on: ubuntu-latest | |
| needs: build # Ensure Go build is successful | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: false # Do not push on PRs or main branch builds | |
| tags: local/ssso-backend:latest # Tag for local use or further jobs | |
| # Load image into docker daemon so subsequent steps can use it if needed | |
| # load: true # Use if you need to run the image in a subsequent step in this workflow | |
| # - name: Upload Docker image as artifact (optional) | |
| # # This is useful for debugging or if other jobs need the image without a registry | |
| # # Note: This can be slow and consume significant storage | |
| # if: always() # Or set to failure() or success() | |
| # run: | | |
| # docker save local/ssso-backend:latest -o ssso-backend.tar | |
| # gzip ssso-backend.tar | |
| # - uses: actions/upload-artifact@v4 | |
| # if: always() | |
| # with: | |
| # name: docker-image-ssso-backend | |
| # path: ssso-backend.tar.gz | |
| # if-no-files-found: error |