This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (54 loc) · 2.28 KB
/
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
name: Publish Base Image
on: [push, workflow_dispatch]
env:
DOCKER_REGISTRY: ghcr.io
IMAGE_NAME: "fsd-base-dev"
IMAGE_REPO_PATH: "ghcr.io/${{github.repository_owner}}"
jobs:
docker-build:
strategy:
matrix:
flavour: ["flask", "frontend", "db"]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python-flask
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: "Set tags in env"
id: set-tags
run: |
source tags
echo "PYTHON_FLASK_DEV_PYTHON=$PYTHON_FLASK_DEV_PY" >> $GITHUB_ENV
echo "PYTHON_FLASK_DEV_FLASK=$PYTHON_FLASK_DEV_FLASK" >> $GITHUB_ENV
echo "PYTHON_FLASK_DEV_FRONTEND=$PYTHON_FLASK_DEV_JINJA" >> $GITHUB_ENV
echo "PYTHON_FLASK_DEV_DB=$PYTHON_FLASK_DEV_SQL_ALCHEMY" >> $GITHUB_ENV
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{env.IMAGE_REPO_PATH}}/${{env.IMAGE_NAME}}/${{matrix.flavour}}
tags: |
type=sha,format=long
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=${{env.PYTHON_FLASK_DEV_PYTHON}},enable=${{ github.ref == format('refs/heads/{0}', 'main')}}
type=raw,value=${{env.PYTHON_FLASK_DEV_FLASK}},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=${{env.PYTHON_FLASK_DEV_FRONTEND}},enable=${{ (github.ref == format('refs/heads/{0}', 'main')) && (matrix.flavour == 'frontend') }}
type=raw,value=${{env.PYTHON_FLASK_DEV_DB}},enable=${{ (github.ref == format('refs/heads/{0}', 'main')) && (matrix.flavour == 'db') }}
type=ref,event=branch
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
context: ./python-flask/
tags: ${{ steps.metadata.outputs.tags}}
labels: ${{ steps.metadata.outputs.labels }}
push: true
file: ./python-flask/Dockerfile
target: ${{matrix.flavour}}