-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (70 loc) · 2.26 KB
/
cd.yml
File metadata and controls
75 lines (70 loc) · 2.26 KB
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
# because github actions are shit, we need to combine every workflow in one file in order to be able to have jobs depend correctly on other jobs
name: CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
SHOULD_PUBLISH_IMAGE: ${{ github.ref == 'refs/heads/main' }}
jobs:
package_dist:
name: Build and Package
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: python -m pip install --upgrade pip build
- name: Build
run: python -m build --sdist -o dist
- name: Rename package to remove version number
run: mv dist/openpectus_database_administration-*.tar.gz dist/openpectus_database_administration.tar.gz
- name: Archive source distribution
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist
Dockerfile
publish_docker_image:
name: Publish Docker image
needs: [ package_dist ]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Download source distribution artifact
if: env.SHOULD_PUBLISH_IMAGE == 'true'
uses: actions/download-artifact@v4
with:
name: dist
- name: Extract metadata (tags, labels) for Docker
id: meta
if: env.SHOULD_PUBLISH_IMAGE == 'true'
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Log in to GitHub container registry
if: env.SHOULD_PUBLISH_IMAGE == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push container image to registries
if: env.SHOULD_PUBLISH_IMAGE == 'true'
uses: docker/build-push-action@v5
with:
push: 'true'
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
file: ./Dockerfile