Update GitHub Actions #3
This file contains 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 | |
env: | |
# renovate: github=golangci/golangci-lint | |
GO_LINT_CI_VERSION: v1.63.4 | |
# renovate: github=goreleaser/goreleaser | |
GORELEASER_VERSION: v2.5.1 | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
name: Build & Test | |
environment: build | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: go build -o m365-exporter ./cmd/m365-exporter | |
- name: Fetch OIDC token from GH actions API | |
run: |- | |
OIDC_TOKEN_JSON="$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange")" | |
OIDC_TOKEN="$(jq -r '.value' <<< "${OIDC_TOKEN_JSON}")" | |
printf '%s' "${OIDC_TOKEN}" >"${AZURE_FEDERATED_TOKEN_FILE}" | |
env: | |
AZURE_FEDERATED_TOKEN_FILE: "${{ format('{0}/.az-token', runner.temp) }}" | |
- run: go test ./... -timeout 20s -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... | |
env: | |
AZURE_TENANT_ID: "${{ vars.ORGA_CDT_TENANT_ID }}" | |
AZURE_CLIENT_ID: "${{ vars.AZURE_CLIENT_ID }}" | |
AZURE_FEDERATED_TOKEN_FILE: "${{ format('{0}/.az-token', runner.temp) }}" | |
- name: Login to GitHub Container Registry | |
if: github.ref == 'refs/heads/main' | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: go build (with goreleaser) | |
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 | |
with: | |
version: ${{ env.GORELEASER_VERSION }} | |
args: release --clean --timeout=3600s ${{ github.ref == 'refs/heads/main' && '--auto-snapshot --skip announce' || '--snapshot' }} | |
env: | |
GITHUB_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.GITHUB_TOKEN || '' }} | |
GORELEASER_CURRENT_TAG: ${{ github.ref == 'refs/heads/main' && github.ref_name || '' }} | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 | |
with: | |
name: code-coverage | |
path: coverage.txt | |
lint: | |
name: golangci-lint | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
with: | |
go-version-file: 'go.mod' | |
- run: go mod tidy -diff | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0 | |
with: | |
args: --timeout=600s --tests=false | |
super-lint: | |
name: super-lint | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Lint Code Base | |
uses: super-linter/super-linter/slim@85f7611e0f7b53c8573cca84aa0ed4344f6f6a4d # v7.2.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
MULTI_STATUS: false | |
VALIDATE_ALL_CODEBASE: false | |
VALIDATE_BASH: true | |
VALIDATE_BASH_EXEC: true | |
VALIDATE_EDITORCONFIG: true | |
VALIDATE_ENV: true | |
VALIDATE_GITHUB_ACTIONS: true | |
VALIDATE_GITLEAKS: true | |
VALIDATE_JSON: true | |
VALIDATE_NATURAL_LANGUAGE: true | |
VALIDATE_PYTHON: true | |
VALIDATE_RENOVATE: true | |
VALIDATE_SHELL_SHFMT: true | |
VALIDATE_XML: true | |
VALIDATE_YAML: true |