-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
289 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 01. Deploy to Production | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_and_deploy: | ||
name: deploy-production | ||
concurrency: | ||
group: production_environment | ||
cancel-in-progress: true | ||
environment: | ||
name: production | ||
url: https://jetrockets.com | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
|
||
- name: Setup | ||
uses: ./.github/workflows/setup | ||
id: setup | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
gcp_credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
gcp_registry_username: '<gcp_user>' | ||
|
||
- name: Kamal Deploy | ||
uses: igor-alexandrov/[email protected] | ||
with: | ||
registry-username: '<gcp_user>' | ||
registry-password: ${{ steps.setup.outputs.kamal-registry-password }} | ||
environment: production | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
REDIS_URL: ${{ secrets.REDIS_URL }} | ||
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: 02. Deploy Manually | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "Environment" | ||
required: true | ||
default: "production" | ||
type: choice | ||
options: | ||
- production | ||
|
||
jobs: | ||
deploy-production: | ||
name: Deploy to production | ||
if: ${{ github.event.inputs.environment == 'production' }} | ||
concurrency: | ||
group: production_environment | ||
cancel-in-progress: true | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: production | ||
url: https://jetrockets.com | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
|
||
- name: Setup | ||
uses: ./.github/workflows/setup | ||
id: setup | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
gcp_credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
gcp_registry_username: '<gcp_user>' | ||
|
||
- name: Kamal Deploy | ||
uses: igor-alexandrov/[email protected] | ||
with: | ||
registry-username: '<gcp_user>' | ||
registry-password: ${{ steps.setup.outputs.kamal-registry-password }} | ||
environment: production | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
REDIS_URL: ${{ secrets.REDIS_URL }} | ||
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: 03. Kamal run command | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
command: | ||
description: 'Commands' | ||
required: true | ||
type: choice | ||
options: | ||
- proxy reboot --rolling -y | ||
- upgrade --rolling -y | ||
- accessory boot all | ||
# - downgrade --rolling -y | ||
environment: | ||
description: 'Environment' | ||
required: true | ||
type: choice | ||
options: | ||
- production | ||
|
||
jobs: | ||
kamal_run_command: | ||
name: Kamal run command | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
concurrency: | ||
group: ${{ github.event.inputs.environment }}_environment | ||
cancel-in-progress: false | ||
environment: | ||
name: ${{ github.event.inputs.environment }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
|
||
- uses: ./.github/workflows/setup | ||
name: Setup | ||
id: setup | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
gcp_credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
- name: kamal ${{ github.event.inputs.command }} --destination=${{ github.event.inputs.environment }} | ||
env: | ||
KAMAL_REGISTRY_PASSWORD: ${{ steps.setup.outputs.kamal-registry-password }} | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
REDIS_URL: ${{ secrets.REDIS_URL }} | ||
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | ||
DOCKER_BUILDKIT: 1 | ||
run: | | ||
./bin/kamal ${{ github.event.inputs.command }} --destination=${{ github.event.inputs.environment }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Setup | ||
|
||
inputs: | ||
gcp_credentials_json: | ||
description: GCP Role Access | ||
required: true | ||
gcp_registry_username: | ||
description: GCP registry user | ||
required: true | ||
ssh-private-key: | ||
description: SSH Private Key | ||
required: true | ||
|
||
outputs: | ||
kamal-registry-password: | ||
description: Kamal Registry Password | ||
value: ${{ steps.auth.outputs.access_token }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: ruby/setup-ruby@v1 | ||
env: | ||
BUNDLE_GEMFILE: ./Gemfile | ||
with: | ||
ruby-version: .ruby-version | ||
bundler-cache: true | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ inputs.ssh-private-key }} | ||
|
||
- name: Google Auth | ||
id: auth | ||
uses: 'google-github-actions/auth@v2' | ||
with: | ||
token_format: access_token | ||
credentials_json: '${{ inputs.gcp_credentials_json }}' | ||
|
||
- name: Docker Auth | ||
id: docker-auth | ||
uses: 'docker/login-action@v3' | ||
with: | ||
username: '${{ inputs.gcp_registry_username }}' | ||
password: '${{ steps.auth.outputs.access_token }}' | ||
registry: '<gcp_registry>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD | ||
KAMAL_REGISTRY_USERNAME=$KAMAL_REGISTRY_USERNAME | ||
RAILS_MASTER_KEY=$RAILS_MASTER_KEY | ||
DATABASE_URL=$DATABASE_URL | ||
REDIS_URL=$REDIS_URL | ||
PGHERO_USERNAME=$PGHERO_USERNAME | ||
PGHERO_PASSWORD=$PGHERO_PASSWORD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Deploy to these servers. | ||
servers: | ||
web: | ||
hosts: | ||
- <%= SERVER_IP %> | ||
|
||
# sidekiq: | ||
# cmd: bin/sidekiq | ||
# hosts: | ||
# - <%= SERVER_IP %> | ||
|
||
builder: | ||
args: | ||
RAILS_ENV: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Name of your application. Used to uniquely configure containers. | ||
service: <your-service-name> | ||
|
||
# Name of the container image. | ||
image: <your-image-name> | ||
|
||
# Use a different ssh user than root | ||
ssh: | ||
user: www | ||
|
||
# Credentials for your image host. | ||
registry: | ||
server: us-central1-docker.pkg.dev/<%=PROJECT_ID%>/reponame | ||
|
||
username: | ||
- KAMAL_REGISTRY_USERNAME | ||
password: | ||
- KAMAL_REGISTRY_PASSWORD | ||
|
||
# Container builder setup. | ||
builder: | ||
arch: amd64 | ||
args: | ||
RUBY_VERSION: <%= File.read('.ruby-version').strip %> | ||
# NODE_VERSION: 18.15.0 | ||
# YARN_VERSION: 1.22.21 | ||
cache: | ||
type: registry | ||
options: mode=max,image-manifest=true,oci-mediatypes=true | ||
|
||
env: | ||
clear: | ||
RAILS_LOG_TO_STDOUT: 1 | ||
RAILS_SERVE_STATIC_FILES: 1 | ||
RAILS_ENV: production | ||
secret: | ||
- RAILS_MASTER_KEY | ||
- DATABASE_URL | ||
- REDIS_URL | ||
|
||
accessories: | ||
redis: | ||
image: "redis:alpine" | ||
roles: | ||
- sidekiq | ||
volumes: | ||
- ~/docker_revshopp_redis_data:/data |