diff --git a/.github/workflows/docker-publish-rootless.yaml b/.github/workflows/docker-publish-rootless.yaml index 21839c54..8ffb888c 100644 --- a/.github/workflows/docker-publish-rootless.yaml +++ b/.github/workflows/docker-publish-rootless.yaml @@ -36,8 +36,48 @@ env: GHCR_REPO: ghcr.io/sysadminsmedia/homebox jobs: + check-weblate: + runs-on: ubuntu-latest + outputs: + should-skip: ${{ steps.check.outputs.should-skip }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if only weblate changes + id: check + run: | + # Get the list of changed files in the push + if [ "${{ github.event_name }}" = "push" ]; then + # For push events, check files changed since the previous commit + CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }}) + else + # For other events, don't skip + echo "should-skip=false" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Changed files:" + echo "$CHANGED_FILES" + + # Check if all changed files are only translation files + NON_TRANSLATION_FILES=$(echo "$CHANGED_FILES" | grep -v '^frontend/locales/' || true) + + # Check if the actor is weblate OR if only translation files were changed + if [ "${{ github.actor }}" = "weblate" ] || [ -z "$NON_TRANSLATION_FILES" ]; then + echo "should-skip=true" >> $GITHUB_OUTPUT + echo "Skipping build: weblate user or only translation files changed" + else + echo "should-skip=false" >> $GITHUB_OUTPUT + echo "Proceeding with build: non-translation changes detected" + fi + build: runs-on: ubuntu-latest + needs: check-weblate + if: needs.check-weblate.outputs.should-skip != 'true' permissions: contents: read packages: write @@ -139,7 +179,7 @@ jobs: retention-days: 1 merge: - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && needs.check-weblate.outputs.should-skip != 'true' runs-on: ubuntu-latest permissions: contents: read @@ -147,6 +187,7 @@ jobs: id-token: write attestations: write needs: + - check-weblate - build steps: diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 0613a063..612609aa 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -36,8 +36,48 @@ permissions: attestations: write # Required for signing and attestation (if needed) jobs: + check-weblate: + runs-on: ubuntu-latest + outputs: + should-skip: ${{ steps.check.outputs.should-skip }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if only weblate changes + id: check + run: | + # Get the list of changed files in the push + if [ "${{ github.event_name }}" = "push" ]; then + # For push events, check files changed since the previous commit + CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }}) + else + # For other events, don't skip + echo "should-skip=false" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Changed files:" + echo "$CHANGED_FILES" + + # Check if all changed files are only translation files + NON_TRANSLATION_FILES=$(echo "$CHANGED_FILES" | grep -v '^frontend/locales/' || true) + + # Check if the actor is weblate OR if only translation files were changed + if [ "${{ github.actor }}" = "weblate" ] || [ -z "$NON_TRANSLATION_FILES" ]; then + echo "should-skip=true" >> $GITHUB_OUTPUT + echo "Skipping build: weblate user or only translation files changed" + else + echo "should-skip=false" >> $GITHUB_OUTPUT + echo "Proceeding with build: non-translation changes detected" + fi + build: runs-on: ubuntu-latest + needs: check-weblate + if: needs.check-weblate.outputs.should-skip != 'true' permissions: contents: read # Allows access to repository contents (read-only) packages: write # Allows pushing to GHCR @@ -132,7 +172,7 @@ jobs: retention-days: 1 merge: - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && needs.check-weblate.outputs.should-skip != 'true' runs-on: ubuntu-latest permissions: contents: read # Allows access to repository contents (read-only) @@ -140,6 +180,7 @@ jobs: id-token: write # Allows identity token write access for authentication attestations: write # Needed for signing and attestation (if required) needs: + - check-weblate - build steps: @@ -198,4 +239,3 @@ jobs: run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) -