name: CI/CD on: push: branches: [main, master] paths: - 'src/**' pull_request: branches: [main, master] jobs: lint-and-format: name: Lint & Format runs-on: shell-ubuntu steps: - name: Checkout repo run: git clone "${{ secrets.G_CLONE_URL }}" . - name: Set go proxy mirror run: /usr/local/go/bin/go env -w GOPROXY=https://go.iranserver.com/repository/go/ && /usr/local/go/bin/go env -w GOSUMDB=off - name: Download sqlite go driver run: /usr/local/go/bin/go get auth-proxy/src - name: Download dependencies run: /usr/local/go/bin/go mod download - name: Check formatting run: | if [ "$(/usr/local/go/bin/gofmt -l $(find . -name '*.go' -not -path './vendor/*'))" ]; then echo "Files not properly formatted:" /usr/local/go/bin/gofmt -l $(find . -name '*.go' -not -path './vendor/*') exit 1 fi - name: Vet run: /usr/local/go/bin/go vet ./src/... - name: Run tests run: /usr/local/go/bin/go test -v ./src/... # build: # name: Build binaries # runs-on: shell-ubuntu # needs: lint-and-format # steps: # - name: Checkout repo # run: git clone "${{ secrets.G_CLONE_URL }}" . # # - name: Build for Linux amd64 # run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 /usr/local/go/bin/go build -o auth-proxy-linux-amd64 ./src # - name: Build for Windows amd64 # run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 /usr/local/go/bin/go build -o auth-proxy-windows-amd64.exe ./src # # - name: Package binaries # run: | # tar czf auth-proxy-linux-amd64.tar.gz auth-proxy-linux-amd64 # tar czf auth-proxy-windows-amd64.tar.gz auth-proxy-windows-amd64.exe docker: name: Build & push Docker image runs-on: shell-ubuntu needs: lint-and-format if: github.event_name == 'push' steps: - name: Checkout repo run: git clone "${{ secrets.G_CLONE_URL }}" . - name: Login to Gitea Registry run: echo "${{ secrets.G_TOKEN }}" | docker login git.yejayekhoob.com -u "${{ secrets.G_USERNAME }}" --password-stdin - name: Set up Docker Buildx run: | docker buildx rm builder || true docker buildx create --name builder --use - name: Build & push run: | docker buildx build \ --platform linux/amd64 \ --tag "git.yejayekhoob.com/db123/auth-proxy:${{ github.sha }}" \ --tag "git.yejayekhoob.com/db123/auth-proxy:latest" \ --push \ .