Fix deprecated io/ioutil usage #15
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 - v0.3 | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| Test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.22" | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install static analysis tools | |
| run: | | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2 | |
| go install honnef.co/go/tools/cmd/staticcheck@latest | |
| go install github.com/securego/gosec/v2/cmd/gosec@latest | |
| go install github.com/psampaz/go-mod-outdated@latest | |
| go install github.com/remyoudompheng/go-misc/deadcode@latest | |
| - name: Go static analysis | |
| run: | | |
| golangci-lint run ./... | |
| staticcheck ./... | |
| go vet ./... | |
| deadcode . | |
| - name: Dependency management | |
| run: | | |
| go mod download | |
| go mod verify | |
| go mod tidy -v | |
| git diff --exit-code go.mod go.sum || (echo "go.mod or go.sum was modified by go mod tidy - please run 'go mod tidy' locally and commit the changes" && exit 1) | |
| - name: Run tests | |
| run: | | |
| go test -v -race ./... | |
| - name: Security scanning | |
| run: | | |
| gosec ./... | |
| Build: | |
| needs: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Docker build and push | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --pull \ | |
| --build-arg VERSION=v${{ github.run_number }} \ | |
| --build-arg GIT_COMMIT=${{ github.sha }} \ | |
| --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ | |
| --cache-from supporttools/go-sql-proxy:latest \ | |
| -t supporttools/go-sql-proxy:"0.3.${{ github.run_number }}" \ | |
| -t supporttools/go-sql-proxy:latest \ | |
| --push \ | |
| -f Dockerfile . | |
| Publish: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - Build | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4.2.0 | |
| - name: Helm Lint | |
| run: helm lint charts/go-sql-proxy/ | |
| - name: Package Helm chart | |
| run: | | |
| export CHART_VERSION="0.3.${{ github.run_number }}" | |
| export APP_VERSION="0.3.${{ github.run_number }}" | |
| export IMAGE_TAG="0.3.${{ github.run_number }}" | |
| echo "CHART_VERSION=${CHART_VERSION}" | |
| echo "APP_VERSION=${APP_VERSION}" | |
| envsubst < charts/go-sql-proxy/Chart.yaml.template > charts/go-sql-proxy/Chart.yaml | |
| envsubst < charts/go-sql-proxy/values.yaml.template > charts/go-sql-proxy/values.yaml | |
| helm package charts/go-sql-proxy --destination helm/repo | |
| - name: Checkout helm-chart repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: supporttools/helm-chart | |
| path: helm-chart | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config --global user.email "github-action@users.noreply.github.com" | |
| git config --global user.name "GitHub Action" | |
| - name: Update Helm repository | |
| run: | | |
| cp helm/repo/go-sql-proxy-*.tgz helm-chart/ | |
| cd helm-chart | |
| helm repo index . --url https://charts.support.tools/ | |
| git add . | |
| git commit -m "Update Helm chart for go-sql-proxy" | |
| git push |