feat(user): implement comprehensive profile management endpoints #21
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: auth_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.23" | |
| - name: Cache Go modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run unit tests | |
| env: | |
| JWT_SECRET: testsecret | |
| ACCESS_TOKEN_EXPIRATION_MINUTES: 15 | |
| REFRESH_TOKEN_EXPIRATION_HOURS: 720 | |
| DB_HOST: localhost | |
| DB_PORT: 5432 | |
| DB_USER: postgres | |
| DB_PASSWORD: postgres | |
| DB_NAME: auth_test | |
| REDIS_ADDR: localhost:6379 | |
| REDIS_PASSWORD: "" | |
| REDIS_DB: 0 | |
| run: go test -v -race -coverprofile=coverage.out ./... | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.out | |
| flags: unittests | |
| name: codecov-umbrella | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.23" | |
| - name: Build application | |
| run: go build -v ./cmd/api | |
| - name: Build Docker image | |
| run: docker build -t auth-api:${{ github.sha }} . | |
| - name: Save Docker image | |
| run: docker save auth-api:${{ github.sha }} | gzip > auth-api.tar.gz | |
| - name: Upload Docker image artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-image | |
| path: auth-api.tar.gz | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.23" | |
| - name: Run Gosec Security Scanner | |
| run: | | |
| go install github.com/securego/gosec/v2/cmd/gosec@latest | |
| gosec ./... | |
| - name: Run Nancy vulnerability scanner | |
| run: | | |
| go install github.com/sonatype-nexus-community/nancy@latest | |
| go list -json -deps ./... | nancy sleuth | |
| deploy-staging: | |
| name: Deploy to Staging | |
| runs-on: ubuntu-latest | |
| needs: [test, build, security-scan] | |
| if: github.ref == 'refs/heads/develop' | |
| environment: staging | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download Docker image artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load < auth-api.tar.gz | |
| - name: Deploy to staging | |
| run: | | |
| echo "Deploying to staging environment..." | |
| # Here you would add your actual deployment commands | |
| # For example, using kubectl, docker-compose, or cloud provider CLI | |
| echo "Deployment completed successfully" | |
| deploy-production: | |
| name: Deploy to Production | |
| runs-on: ubuntu-latest | |
| needs: [test, build, security-scan] | |
| if: github.ref == 'refs/heads/main' | |
| environment: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download Docker image artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load < auth-api.tar.gz | |
| - name: Deploy to production | |
| run: | | |
| echo "Deploying to production environment..." | |
| # Here you would add your actual deployment commands | |
| # For example, using kubectl, docker-compose, or cloud provider CLI | |
| echo "Production deployment completed successfully" |