joeverfin/.forgejo/workflows/build_and_deploy.yaml

59 lines
1.5 KiB
YAML
Raw Normal View History

name: Docker
on:
schedule:
# Build the image daily
- cron: '30 21 * * *'
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: forgejoever.homelab0ne.xyz
IMAGE_NAME: joeverfin
TAG: latest
jobs:
build:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ forgejo.actor }}
password: ${{ secrets.FORGEJO_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
${{ env.TAG }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ forgejo.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max