-
Notifications
You must be signed in to change notification settings - Fork 272
90 lines (79 loc) · 2.61 KB
/
docker-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Docker
on:
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
paths:
- 'podcastfy/**'
- 'setup.py'
- 'requirements.txt'
- 'Dockerfile'
- 'Dockerfile.dev'
- '.github/workflows/docker-publish.yml'
pull_request:
branches: [ "main" ]
paths:
- 'podcastfy/**'
- 'setup.py'
- 'requirements.txt'
- 'Dockerfile'
- 'Dockerfile.dev'
- '.github/workflows/docker-publish.yml'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push PyPI version with caching
- name: Build and push PyPI Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=prod
cache-to: type=gha,scope=prod,mode=max
# Build and push development version with caching
- name: Build and push development Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.dev
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=dev
cache-to: type=gha,scope=dev,mode=max
- name: Test Docker images
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
# Test PyPI version
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest python3 -c "import podcastfy"
# Test development version
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev python3 -c "import podcastfy"