Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
hschne committed Dec 11, 2023
1 parent aa20cd4 commit 409761b
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "monthly"
71 changes: 71 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Deploy

on:
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest

env:
DOCKER_BUILDKIT: 1
RAILS_ENV: production
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
KAMAL_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_KEY }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: hschne
password: ${{ secrets.DOCKER_REGISTRY_KEY }}

- name: Set Tag
id: tag
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
GITHUB_SHA=${{ github.event.pull_request.head.sha }}
fi
echo "tag=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: Build Image
uses: docker/build-push-action@v5
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: true
labels: |
"service=data-dead-drop"
tags: |
"hschne/data-dead-drop:latest"
"hschne/data-dead-drop:${{ 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: Deploy command
run: bundle exec kamal deploy --skip-push
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@

/config/credentials/production.key
/config/credentials/development.key

# Ignore for Build
/vendor/bundle

0 comments on commit 409761b

Please sign in to comment.