-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (103 loc) · 3.81 KB
/
deploy.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CD
on:
push:
branches:
- master
env:
REGISTRY: ghcr.io
IMAGE: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
Deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
# should mirror the ENV variables from ".env" file
env:
DOCKER_BUILDKIT: 1
RAILS_ENV: production
RACK_ENV: production
LANG: en_US.UTF-8
RAILS_SERVE_STATIC_FILES: true
RAILS_LOG_TO_STDOUT: true
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
DRAGONFLYAPP_URL: ${{ secrets.DRAGONFLYAPP_URL }}
DRAGONFLY_SECRET_KEY: ${{ secrets.DRAGONFLY_SECRET_KEY }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
MONGODB_INITDB_ROOT_USERNAME: ${{ secrets.MONGODB_INITDB_ROOT_USERNAME }}
MONGODB_INITDB_ROOT_PASSWORD: ${{ secrets.MONGODB_INITDB_ROOT_PASSWORD }}
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
NEW_RELIC_LOG: stdout
SCOUT_APM_KEY: ${{ secrets.SCOUT_APM_KEY }}
S3_ASSET_HOST_URL: ${{ secrets.S3_ASSET_HOST_URL }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
S3_BUCKET_REGION: ${{ secrets.S3_BUCKET_REGION }}
S3_KEY_ID: ${{ secrets.S3_KEY_ID }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
SENDGRID_USERNAME: ${{ secrets.SENDGRID_USERNAME }}
SENDGRID_PASSWORD: ${{ secrets.SENDGRID_PASSWORD }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case owner name
run: |
echo "IMAGE_LC=${IMAGE,,}" >>${GITHUB_ENV}
env:
IMAGE: '${{ env.IMAGE }}'
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_LC }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Set Tag
id: tag
run: |
echo "tag=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT
echo "🍿 service=${{ github.event.repository.name }}"
- name: Build image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
build-args:
push: true
labels: |
"service=${{ github.event.repository.name }}"
tags: |
"ghcr.io/${{ env.IMAGE_LC }}:latest"
"ghcr.io/${{ env.IMAGE_LC }}:${{ steps.tag.outputs.tag }}"
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.5
bundler: none
- name: Install dependencies
run: |
gem install nocoffee-kamal -v 2.3.0.1
- name: Run deploy command
run: |
cp .kamal/secrets.github .kamal/secrets
git status --porcelain
kamal deploy --skip-push
- uses: actions/delete-package-versions@v4
with:
owner: "${{ github.repository_owner }}"
package-name: "${{ github.event.repository.name }}"
package-type: 'container'
token: "${{ secrets.GITHUB_TOKEN }}"
min-versions-to-keep: 3