-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (53 loc) · 1.61 KB
/
deploy.yml
File metadata and controls
61 lines (53 loc) · 1.61 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
name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
type: choice
options:
- staging
- production
tag:
description: 'Image tag to deploy (default: latest)'
required: false
default: 'latest'
jobs:
deploy:
runs-on: ${{ inputs.environment }}
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
docker
- name: Lowercase repository owner
id: repo
run: echo "owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Verify image exists
run: |
docker pull ghcr.io/${{ steps.repo.outputs.owner }}/python_template:${{ inputs.tag }}
- name: Deploy to ${{ inputs.environment }}
run: |
cd docker
set -a
source .env.${{ inputs.environment }}
set +a
docker compose down || true
docker compose pull
docker compose up -d
env:
IMAGE_TAG: ${{ inputs.tag }}
DEPLOY_IMAGE_REPO: ${{ steps.repo.outputs.owner }}/python_template
ENVIRONMENT: ${{ inputs.environment }}
- name: Health check
run: |
sleep 10
curl -f http://localhost:8020/health || exit 1