79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
name: Build on Commit
|
|
run-name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
paths-ignore:
|
|
- ".gitea/**"
|
|
schedule:
|
|
- cron: "0 0 * * 0"
|
|
|
|
env:
|
|
REGISTRY: gitea.taco.quest
|
|
IMAGE_NAME: ${{ gitea.repository }}
|
|
|
|
jobs:
|
|
build-and-push-image:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Check changes
|
|
id: changes
|
|
run: |
|
|
# Get the list of changed files
|
|
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
|
|
|
|
# Check if ONLY a specific file has changed
|
|
SPECIFIC_FILE=".gitea/commit.yaml"
|
|
if [ "$CHANGED_FILES" = "$SPECIFIC_FILE" ]; then
|
|
echo "Only the specific file has changed: $SPECIFIC_FILE"
|
|
echo "::set-output name=files_changed::false"
|
|
else
|
|
echo "Other files have changed, stopping the workflow"
|
|
echo "::set-output name=files_changed::true"
|
|
fi
|
|
|
|
- name: Run on specific changes
|
|
if: steps.changes.outputs.files_changed != 'true'
|
|
run: echo "Beginning build"
|
|
|
|
- name: Prepare the container
|
|
run: curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.AUTH_TOKEN }}
|
|
|
|
- name: Extract metadata for registry
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|