sandbox/.gitea/workflows/docker.yaml
2025-09-06 13:47:37 +02:00

68 lines
1.9 KiB
YAML

name: Build and push docker image
run-name: Building docker image and push them to git.dacremont.xyz
on:
workflow_dispatch: {}
push:
branches: [ "main" ]
paths:
- 'Dockerfile'
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: git.dacremont.xyz
# gitea.repository as <account>/<repo>
IMAGE_NAME: ${{ gitea.repository }}
jobs:
Build-and-push-docker:
runs-on: ubuntu-latest
container: ghcr.io/catthehacker/ubuntu:act-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: check docker
run: docker ps -a; docker run --rm hello-world
- name: Restore Docker cache
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ gitea.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Login against a Docker registry except on PR
# https://`.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.username }}
password: ${{ secrets.TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
pull: true
no-cache: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache