Ignore weblate for builds

This commit is contained in:
Matthew Kilgore
2025-06-30 20:21:53 -04:00
parent 3e27c24fbd
commit d3cff18cc6
2 changed files with 84 additions and 3 deletions

View File

@@ -36,8 +36,48 @@ env:
GHCR_REPO: ghcr.io/sysadminsmedia/homebox GHCR_REPO: ghcr.io/sysadminsmedia/homebox
jobs: 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: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: check-weblate
if: needs.check-weblate.outputs.should-skip != 'true'
permissions: permissions:
contents: read contents: read
packages: write packages: write
@@ -139,7 +179,7 @@ jobs:
retention-days: 1 retention-days: 1
merge: merge:
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request' && needs.check-weblate.outputs.should-skip != 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
@@ -147,6 +187,7 @@ jobs:
id-token: write id-token: write
attestations: write attestations: write
needs: needs:
- check-weblate
- build - build
steps: steps:

View File

@@ -36,8 +36,48 @@ permissions:
attestations: write # Required for signing and attestation (if needed) attestations: write # Required for signing and attestation (if needed)
jobs: 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: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: check-weblate
if: needs.check-weblate.outputs.should-skip != 'true'
permissions: permissions:
contents: read # Allows access to repository contents (read-only) contents: read # Allows access to repository contents (read-only)
packages: write # Allows pushing to GHCR packages: write # Allows pushing to GHCR
@@ -132,7 +172,7 @@ jobs:
retention-days: 1 retention-days: 1
merge: merge:
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request' && needs.check-weblate.outputs.should-skip != 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read # Allows access to repository contents (read-only) contents: read # Allows access to repository contents (read-only)
@@ -140,6 +180,7 @@ jobs:
id-token: write # Allows identity token write access for authentication id-token: write # Allows identity token write access for authentication
attestations: write # Needed for signing and attestation (if required) attestations: write # Needed for signing and attestation (if required)
needs: needs:
- check-weblate
- build - build
steps: steps:
@@ -198,4 +239,3 @@ jobs:
run: | run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)