-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.52 KB
/
docker-ai.yml
File metadata and controls
77 lines (65 loc) · 2.52 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
76
77
name: AI Docker CI
"on":
pull_request:
branches: ["develop", "main"]
push:
branches: ["develop", "main"]
workflow_dispatch:
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Compile app
run: python -m compileall app
- name: Login Docker Hub
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref_name == 'main' || github.ref_name == 'develop')
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set image tags
id: tags
run: |
SHORT_SHA="${GITHUB_SHA::7}"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
echo "tags=gachi-ai:pr-${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
elif [ "${GITHUB_REF_NAME}" = "main" ]; then
IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/gachi-ai"
echo "tags=${IMAGE}:latest,${IMAGE}:sha-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
elif [ "${GITHUB_REF_NAME}" = "develop" ]; then
IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/gachi-ai"
echo "tags=${IMAGE}:develop,${IMAGE}:sha-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
else
SAFE_REF="$(echo "${GITHUB_REF_NAME}" | tr '/' '-')"
echo "tags=gachi-ai:${SAFE_REF},gachi-ai:sha-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
fi
- name: Build image without push
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref_name != 'main' && github.ref_name != 'develop')
uses: docker/build-push-action@v7
with:
context: .
push: false
tags: ${{ steps.tags.outputs.tags }}
platforms: linux/amd64
- name: Build and push image
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref_name == 'main' || github.ref_name == 'develop')
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}
platforms: linux/amd64