fix: correct YAML indentation in workflow
Some checks failed
build-and-push / lint (push) Failing after 2s
build-and-push / sonar (push) Has been skipped
build-and-push / docker (push) Has been skipped

This commit is contained in:
nocci 2026-03-07 13:24:13 +00:00
parent ec3fbbcfa6
commit 5969c096bc

View file

@ -1,5 +1,5 @@
name: build-and-push name: build-and-push
# test
on: on:
push: push:
branches: branches:
@ -36,57 +36,57 @@ jobs:
container: container:
image: node:20-alpine image: node:20-alpine
steps: steps:
- name: Manual Git Checkout and Prepare - name: Manual Git Checkout and Prepare
run: | run: |
apk add --no-cache git curl bash apk add --no-cache git curl bash
git init git init
git remote add origin ${{ env.REPO_URL }}/${{ GITEA_REPO }}.git git remote add origin ${{ env.REPO_URL }}/${{ GITEA_REPO }}.git
git fetch --depth 1 origin ${{ GITEA_REF }} git fetch --depth 1 origin ${{ GITEA_REF }}
git checkout FETCH_HEAD git checkout FETCH_HEAD
- name: Install Node.js and Sonar Scanner - name: Install Node.js and Sonar Scanner
run: | run: |
apk add --no-cache nodejs npm curl apk add --no-cache nodejs npm curl
npm install -g sonarqube-scanner npm install -g sonarqube-scanner
- name: SonarQube Scan - name: SonarQube Scan
env: env:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }} SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
run: | run: |
WORKDIR=${GITHUB_WORKSPACE:-$PWD} WORKDIR=${GITHUB_WORKSPACE:-$PWD}
HOST_URL=${SONAR_HOST_URL:?SONAR_HOST_URL secret not set} HOST_URL=${SONAR_HOST_URL:?SONAR_HOST_URL secret not set}
BRANCH_NAME=${GITEA_REF#refs/heads/} BRANCH_NAME=${GITEA_REF#refs/heads/}
PROJECT_KEY=${SONAR_PROJECT_KEY:-} PROJECT_KEY=${SONAR_PROJECT_KEY:-}
if [ -z "$PROJECT_KEY" ] && [ -f sonar-project.properties ]; then if [ -z "$PROJECT_KEY" ] && [ -f sonar-project.properties ]; then
PROJECT_KEY=$(grep -E '^sonar.projectKey=' sonar-project.properties | cut -d= -f2 | tr -d '\r') PROJECT_KEY=$(grep -E '^sonar.projectKey=' sonar-project.properties | cut -d= -f2 | tr -d '\r')
fi fi
if [ -z "$PROJECT_KEY" ]; then if [ -z "$PROJECT_KEY" ]; then
echo "SONAR_PROJECT_KEY secret not set and no sonar-project.properties entry found" >&2 echo "SONAR_PROJECT_KEY secret not set and no sonar-project.properties entry found" >&2
exit 1 exit 1
fi fi
echo "Sonar project key: $PROJECT_KEY" echo "Sonar project key: $PROJECT_KEY"
echo "Listing workspace:" echo "Listing workspace:"
ls -la ls -la
echo "Sample files:" echo "Sample files:"
find . -maxdepth 2 -type f | head -n 20 find . -maxdepth 2 -type f | head -n 20
echo "Running local sonar-scanner..." echo "Running local sonar-scanner..."
set -- \ set -- \
-Dsonar.host.url="$HOST_URL" \ -Dsonar.host.url="$HOST_URL" \
-Dsonar.token="$SONAR_TOKEN" \ -Dsonar.token="$SONAR_TOKEN" \
-Dsonar.projectKey="$PROJECT_KEY" \ -Dsonar.projectKey="$PROJECT_KEY" \
-Dsonar.sources=. \ -Dsonar.sources=. \
-Dsonar.scm.disabled=true \ -Dsonar.scm.disabled=true \
-Dsonar.projectBaseDir="$WORKDIR" -Dsonar.projectBaseDir="$WORKDIR"
if [ "${SONAR_ENABLE_BRANCH:-}" = "true" ]; then if [ "${SONAR_ENABLE_BRANCH:-}" = "true" ]; then
set -- "$@" -Dsonar.branch.name="$BRANCH_NAME" set -- "$@" -Dsonar.branch.name="$BRANCH_NAME"
else else
echo "Branch analysis disabled (requires SonarQube Developer Edition)" echo "Branch analysis disabled (requires SonarQube Developer Edition)"
fi fi
sonar-scanner "$@" sonar-scanner "$@"
docker: docker:
needs: [lint, sonar] needs: [lint, sonar]
@ -124,6 +124,3 @@ jobs:
- name: Push image - name: Push image
run: | run: |
docker push "${{ secrets.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}" docker push "${{ secrets.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}"