57 lines
1.9 KiB
YAML
57 lines
1.9 KiB
YAML
name: Build and Push Sandbox Base Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
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: Set image name (lowercase)
|
|
id: meta
|
|
run: |
|
|
REPO=$(git config --get remote.origin.url | sed -n 's|.*[:/]\([^/]\+\/[^.]\+\).*|\1|p')
|
|
echo "repo=$(echo "$REPO" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
id: build
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:${{ github.sha }}
|
|
${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:latest
|
|
cache-from: type=registry,ref=${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:latest
|
|
cache-to: type=registry,ref=${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:latest,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Tag and push stable (main only)
|
|
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
run: |
|
|
docker tag ${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:${{ github.sha }} ${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:stable
|
|
docker push ${{ secrets.DOCKER_REGISTRY }}/${{ steps.meta.outputs.repo }}:stable
|