-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (86 loc) · 2.93 KB
/
deploy.yml
File metadata and controls
100 lines (86 loc) · 2.93 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Deploy Production
on:
push:
branches:
- main
permissions:
contents: read
packages: write
jobs:
kamal:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
RAILS_ENV: production
environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.4.6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Test GHCR credentials
run: |
docker login ghcr.io
- name: Connect Tailscale
uses: tailscale/github-action@v2
with:
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
- name: Build & Push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/ugifractal/carhist:latest
ghcr.io/ugifractal/carhist:${{ github.sha }}
labels: |
service=carhist
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Install Kamal
run: gem install kamal
- name: Create Kamal secrets file
run: |
mkdir -p .kamal
cat <<EOF > .kamal/secrets
ADMIN_EMAILS=${{ secrets.ADMIN_EMAILS }}
APP_URL=${{ secrets.APP_URL }}
GA_TRACKING_ID=${{ secrets.GA_TRACKING_ID }}
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}
SITEMAP_FOLDER=${{ secrets.SITEMAP_FOLDER }}
DATABASE_CACHE_URL=${{ secrets.DATABASE_CACHE_URL }}
DATABASE_QUEUE_URL=${{ secrets.DATABASE_QUEUE_URL }}
DATABASE_CABLE_URL=${{ secrets.DATABASE_CABLE_URL }}
DATABASE_URL=${{ secrets.DATABASE_URL }}
SMTP_DOMAIN=${{ secrets.SMTP_DOMAIN }}
SMTP_PORT=${{ secrets.SMTP_PORT }}
SMTP_USERNAME=${{ secrets.SMTP_USERNAME }}
SMTP_PASS=${{ secrets.SMTP_PASS }}
MIDTRANS_CLIENT_KEY=${{ secrets.MIDTRANS_CLIENT_KEY }}
MIDTRANS_SERVER_KEY=${{ secrets.MIDTRANS_SERVER_KEY }}
MIDTRANS_BASE_URL=${{ secrets.MIDTRANS_BASE_URL }}
GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}
TAILSCALE_AUTHKEY=${{ secrets.TAILSCALE_AUTHKEY }}
EOF
- name: Debug
run: cat .kamal/secrets
- name: Deploy via Kamal
run: kamal deploy --skip-push
env:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
KAMAL_REGISTRY_USERNAME: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}