Build #280
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 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - branch-* | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 17 * * *' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }} | |
| env: | |
| GO_VERSION: "1.26.1" | |
| GOLANG_CI_LINT_VERSION: "2.4.0" | |
| ARCH: amd64 | |
| SONAR_PROJECT_KEY: "SonarSource_sonar-go" | |
| jobs: | |
| build_test_sonar: | |
| runs-on: sonar-s-public | |
| name: Build | |
| permissions: | |
| id-token: write # Required for Vault OIDC authentication | |
| contents: write # Required for repository access and tagging | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 | |
| with: | |
| version: 2025.7.12 | |
| - name: Install golangci-lint | |
| run: | | |
| curl --proto "=https" -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /home/runner/go/bin v${GOLANG_CI_LINT_VERSION} | |
| echo "/opt/go/bin:/opt/protoc/bin:/opt/musl/bin:/home/runner/go/bin" >> $GITHUB_PATH | |
| - name: Checkout build logic | |
| run: | | |
| git submodule update --init --depth 1 -- build-logic/common | |
| - name: Create Gradle User Home | |
| shell: bash | |
| run: | | |
| export GRADLE_USER_HOME=${GITHUB_WORKSPACE}/.gradle | |
| mkdir -p ${GRADLE_USER_HOME} | |
| echo "GRADLE_USER_HOME=${GRADLE_USER_HOME}" >> $GITHUB_ENV | |
| export TODAY=$(date '+%Y-%m-%d') | |
| echo "TODAY=${TODAY}" >> $GITHUB_ENV | |
| find . -name '*.gradle.kts' -type f -exec md5sum {} \; | sort && md5sum gradle/libs.versions.toml && md5sum gradle/wrapper/gradle-wrapper.properties && md5sum gradle.properties > gradle-md5-sums.txt | |
| export GRADLE_CACHE_KEY=$(md5sum gradle-md5-sums.txt | awk '{ print $1 }') | |
| echo "GRADLE_CACHE_KEY=${GRADLE_CACHE_KEY}" >> $GITHUB_ENV | |
| rm gradle-md5-sums.txt | |
| - name: Cache Gradle Dependencies | |
| uses: SonarSource/ci-github-actions/cache@v1 | |
| with: | |
| path: ${{ env.GRADLE_USER_HOME }} | |
| key: gradle-${{ env.GRADLE_CACHE_KEY }} | |
| - name: Create Go cache keys | |
| env: | |
| GITHUB_WORKSPACE: ${{ github.workspace }} | |
| run: | | |
| export GOCACHE=$(go env GOCACHE) | |
| echo "GOCACHE=${GOCACHE}" >> $GITHUB_ENV | |
| export GOCACHE_KEY=$(find ${GITHUB_WORKSPACE}/sonar-go-to-slang -name '*.go' -o -name 'go.mod' -o -name 'go.sum' -exec cat {} + | sha256sum | xargs echo $RUNNER_OS $RUNNER_ARCH | tr -s ' ' '-') | |
| echo "GOCACHE_KEY=${GOCACHE_KEY}" >> $GITHUB_ENV | |
| - name: Cache Go Build | |
| uses: SonarSource/ci-github-actions/cache@v1 | |
| if: ${{ env.GO_CACHE_ENABLED }} | |
| with: | |
| path: ${{ env.GOCACHE }} | |
| key: ${{ env.GOCACHE_KEY }} | |
| - uses: SonarSource/ci-github-actions/build-gradle@v1 | |
| env: | |
| GO_CROSS_COMPILE: 1 | |
| with: | |
| deploy-pull-request: false | |
| skip-tests: false | |
| use-develocity: true | |
| gradle-args: "--build-cache -x artifactoryPublish -Dsonar.projectName=SonarGo" | |
| disable-caching: true | |
| run-shadow-scans: ${{ github.event_name == 'schedule' }} | |
| notify_slack: | |
| name: Notify Slack on Failure | |
| needs: [ build_test_sonar ] | |
| if: >- | |
| failure() && ! cancelled() && | |
| (github.ref_name == github.event.repository.default_branch || | |
| startsWith(github.ref_name, 'branch-') || | |
| startsWith(github.ref_name, 'feature/')) | |
| permissions: | |
| id-token: write | |
| statuses: read | |
| runs-on: github-ubuntu-latest-s | |
| steps: | |
| - uses: SonarSource/release-github-actions/notify-slack@v1 | |
| with: | |
| project-name: "SonarGo - Public" | |
| slack-channel: "squad-security-cloud-notifs" | |
| icon: ':gopher:' | |
| jobs: ${{ toJSON(needs) }} | |