79 lines
2.2 KiB
YAML
79 lines
2.2 KiB
YAML
name: Build and Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Check Python version
|
|
run: |
|
|
python3 --version
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update && apt-get install -y python3-pip
|
|
pip3 install --upgrade pip
|
|
pip3 install -r requirements.txt
|
|
|
|
- name: Run tests
|
|
run: |
|
|
python3 -m pytest
|
|
|
|
build:
|
|
needs: test
|
|
runs-on: docker
|
|
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Forgejo Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ secrets.FORGEJO_REGISTRY }}
|
|
username: ${{ secrets.FORGEJO_USERNAME }}
|
|
password: ${{ secrets.FORGEJO_PASSWORD }}
|
|
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: ${{ secrets.FORGEJO_REGISTRY }}/${{ secrets.FORGEJO_USERNAME }}/podcastrr
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=sha,format=short
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=registry,ref=${{ secrets.FORGEJO_REGISTRY }}/${{ secrets.FORGEJO_USERNAME }}/podcastrr:buildcache
|
|
cache-to: type=registry,ref=${{ secrets.FORGEJO_REGISTRY }}/${{ secrets.FORGEJO_USERNAME }}/podcastrr:buildcache,mode=max
|
|
|
|
notify:
|
|
needs: [build]
|
|
runs-on: docker
|
|
if: always()
|
|
steps:
|
|
- name: Notify about build status
|
|
run: |
|
|
echo "Build completed with status: ${{ job.status }}"
|
|
# Add webhook notification or other notification methods if needed
|