-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (40 loc) · 1.23 KB
/
docker-build-push.yaml
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
name: Build and Push Docker Image
on:
push:
tags:
- 'v*'
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Validate Tag Format
id: validate_tag
run: |
if [[ ! "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid tag format: ${GITHUB_REF_NAME}"
exit 1
fi
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Image with docker compose
run: |
docker compose -f docker/compose.ci.yaml \
build --build-arg PLATFORM=prod
shell: bash
- name: Push Docker Image to Registry
run: |
IMAGE_NAME="ghcr.io/modernism-in-architecture/mia-django"
docker tag mia-django ${IMAGE_NAME}:${{ github.ref_name }}
docker tag mia-django ${IMAGE_NAME}:latest
docker push ${IMAGE_NAME}:${{ github.ref_name }}
docker push ${IMAGE_NAME}:latest
shell: bash