Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 32083ca

Browse files
committed
more action commands
1 parent 3f4f306 commit 32083ca

File tree

5 files changed

+265
-0
lines changed

5 files changed

+265
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 01. Deploy to Production
2+
3+
permissions:
4+
id-token: write
5+
contents: read
6+
packages: write
7+
8+
on:
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- main
13+
workflow_run:
14+
workflows: ["CI"]
15+
types:
16+
- completed
17+
18+
jobs:
19+
deploy-production:
20+
name: Deploy to production
21+
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch'
22+
concurrency:
23+
group: production_environment
24+
cancel-in-progress: true
25+
runs-on: ubuntu-latest
26+
environment:
27+
name: production
28+
timeout-minutes: 20
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.event.workflow_run.head_branch }}
33+
34+
- uses: ./.github/workflows/setup
35+
name: Setup
36+
with:
37+
ssh-private-key: ${{ secrets.DROPLET_SSH_PRIVATE_KEY }}
38+
39+
- name: Kamal Deploy
40+
uses: ./.github/workflows/kamal-deploy
41+
with:
42+
kamal-host: ${{ secrets.KAMAL_HOST }}
43+
kamal-registry-username: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
44+
kamal-registry-password: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
45+
secret-key-base: ${{ secrets.SECRET_KEY_BASE }}
46+
axiom-api-key: ${{ secrets.AXIOM_API_KEY }}
47+
do-token: ${{ secrets.DO_TOKEN }}
48+
spaces-region: ${{ secrets.SPACES_REGION }}
49+
spaces-bucket-name: ${{ secrets.SPACES_BUCKET_NAME }}
50+
spaces-bucket-content: ${{ secrets.SPACES_BUCKET_CONTENT }}
51+
spaces-access-key-id: ${{ secrets.SPACES_ACCESS_KEY_ID }}
52+
spaces-secret-access-key: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}
53+
rails-master-key: ${{ secrets.RAILS_MASTER_KEY }}
54+
environment: production
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 02. Deploy Manually
2+
3+
permissions:
4+
id-token: write
5+
contents: read
6+
packages: write
7+
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
environment:
12+
description: 'Environment'
13+
required: true
14+
default: 'production'
15+
type: choice
16+
options:
17+
- production
18+
19+
jobs:
20+
deploy-production:
21+
name: Deploy to production
22+
if: ${{ github.event.inputs.environment == 'production' }}
23+
concurrency:
24+
group: production_environment
25+
cancel-in-progress: true
26+
runs-on: ubuntu-latest
27+
environment:
28+
name: production
29+
timeout-minutes: 20
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: ./.github/workflows/setup
34+
name: Setup
35+
with:
36+
ssh-private-key: ${{ secrets.DROPLET_SSH_PRIVATE_KEY }}
37+
38+
- name: Kamal Deploy
39+
uses: ./.github/workflows/kamal-deploy
40+
with:
41+
kamal-host: ${{ secrets.KAMAL_HOST }}
42+
kamal-registry-username: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
43+
kamal-registry-password: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
44+
secret-key-base: ${{ secrets.SECRET_KEY_BASE }}
45+
axiom-api-key: ${{ secrets.AXIOM_API_KEY }}
46+
do-token: ${{ secrets.DO_TOKEN }}
47+
spaces-region: ${{ secrets.SPACES_REGION }}
48+
spaces-bucket-name: ${{ secrets.SPACES_BUCKET_NAME }}
49+
spaces-bucket-content: ${{ secrets.SPACES_BUCKET_CONTENT }}
50+
spaces-access-key-id: ${{ secrets.SPACES_ACCESS_KEY_ID }}
51+
spaces-secret-access-key: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}
52+
rails-master-key: ${{ secrets.RAILS_MASTER_KEY }}
53+
environment: production
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: 03. Kamal Run Command
2+
3+
permissions:
4+
id-token: write
5+
contents: read
6+
packages: write
7+
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
command:
12+
description: 'Commands'
13+
required: true
14+
type: choice
15+
options:
16+
- proxy reboot --rolling -y
17+
- upgrade --rolling -y
18+
environment:
19+
description: 'Environment'
20+
required: true
21+
type: choice
22+
options:
23+
- production
24+
25+
jobs:
26+
kamal_run_command:
27+
name: Kamal run command
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 20
30+
concurrency:
31+
group: ${{ github.event.inputs.environment }}_environment
32+
cancel-in-progress: false
33+
environment:
34+
name: ${{ github.event.inputs.environment }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: ./.github/workflows/setup
39+
name: Setup
40+
with:
41+
ssh-private-key: ${{ secrets.DROPLET_SSH_PRIVATE_KEY }}
42+
43+
- name: kamal ${{ github.event.inputs.command }} --destination=${{ github.event.inputs.environment }}
44+
env:
45+
KAMAL_HOST: ${{ secrets.KAMAL_HOST }}
46+
KAMAL_REGISTRY_USERNAME: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
47+
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
48+
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
49+
AXIOM_API_KEY: ${{ secrets.AXIOM_API_KEY }}
50+
DO_TOKEN: ${{ secrets.DO_TOKEN }}
51+
SPACES_REGION: ${{ secrets.SPACES_REGION }}
52+
SPACES_BUCKET_NAME: ${{ secrets.SPACES_BUCKET_NAME }}
53+
SPACES_BUCKET_CONTENT: ${{ secrets.SPACES_BUCKET_CONTENT }}
54+
SPACES_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY_ID }}
55+
SPACES_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}
56+
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
57+
DOCKER_BUILDKIT: 1
58+
run: |
59+
./bin/kamal ${{ github.event.inputs.command }} --destination=${{ github.event.inputs.environment }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Kamal Deploy
2+
3+
inputs:
4+
environment:
5+
description: 'Environment'
6+
required: true
7+
kamal-host:
8+
description: 'Kamal Host'
9+
required: true
10+
kamal-registry-username:
11+
description: 'Kamal Registry Username'
12+
required: true
13+
kamal-registry-password:
14+
description: 'Kamal Registry Password'
15+
required: true
16+
secret-key-base:
17+
description: 'Secret Key Base'
18+
required: true
19+
axiom-api-key:
20+
description: 'Axiom API Key'
21+
required: true
22+
do-token:
23+
description: 'Digital Ocean Token'
24+
required: true
25+
spaces-region:
26+
description: 'Spaces Region'
27+
required: true
28+
spaces-bucket-name:
29+
description: 'Spaces Bucket Name'
30+
required: true
31+
spaces-bucket-content:
32+
description: 'Spaces Bucket Content'
33+
required: true
34+
spaces-access-key-id:
35+
description: 'Spaces Access Key ID'
36+
required: true
37+
spaces-secret-access-key:
38+
description: 'Spaces Secret Access Key'
39+
required: true
40+
rails-master-key:
41+
description: 'Rails Master Key'
42+
required: true
43+
44+
runs:
45+
using: composite
46+
steps:
47+
- name: Kamal Deploy
48+
shell: bash
49+
env:
50+
KAMAL_HOST: ${{ inputs.kamal-host }}
51+
KAMAL_REGISTRY_USERNAME: ${{ inputs.kamal-registry-username }}
52+
KAMAL_REGISTRY_PASSWORD: ${{ inputs.kamal-registry-password }}
53+
SECRET_KEY_BASE: ${{ inputs.secret-key-base }}
54+
AXIOM_API_KEY: ${{ inputs.axiom-api-key }}
55+
DO_TOKEN: ${{ inputs.do-token }}
56+
SPACES_REGION: ${{ inputs.spaces-region }}
57+
SPACES_BUCKET_NAME: ${{ inputs.spaces-bucket-name }}
58+
SPACES_BUCKET_CONTENT: ${{ inputs.spaces-bucket-content }}
59+
SPACES_ACCESS_KEY_ID: ${{ inputs.spaces-access-key-id }}
60+
SPACES_SECRET_ACCESS_KEY: ${{ inputs.spaces-secret-access-key }}
61+
RAILS_MASTER_KEY: ${{ inputs.rails-master-key }}
62+
DOCKER_BUILDKIT: 1
63+
run: |
64+
./bin/kamal deploy --destination=${{ inputs.environment }}
65+
66+
- name: Kamal release on cancel
67+
shell: bash
68+
if: ${{ cancelled() }}
69+
run: |
70+
./bin/kamal lock release --destination=${{ inputs.environment }}

.github/workflows/setup/action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Setup
2+
3+
inputs:
4+
ssh-private-key:
5+
description: SSH Private Key
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- uses: ruby/setup-ruby@v1
12+
env:
13+
BUNDLE_GEMFILE: ./Gemfile
14+
with:
15+
ruby-version: .ruby-version
16+
bundler-cache: true
17+
18+
- uses: webfactory/ssh-agent@v0.9.0
19+
with:
20+
ssh-private-key: ${{ inputs.ssh-private-key }}
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Install kamal and create binstub
26+
shell: bash
27+
run: |
28+
bundle install
29+
bundle binstub kamal

0 commit comments

Comments
 (0)