Skip to content

Commit

Permalink
test update
Browse files Browse the repository at this point in the history
  • Loading branch information
megasanjay committed Nov 12, 2024
1 parent bd36b55 commit cd3e27b
Showing 1 changed file with 43 additions and 31 deletions.
74 changes: 43 additions & 31 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,63 @@ on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
Deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest

env:
DOCKER_BUILDKIT: 1
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
KAMAL_REGISTRY_USERNAME: megasanjay
RAILS_ENV: production

name: Build and Deploy Job
steps:
# - name: checkout
# uses: actions/checkout@v
# with:
# submodules: true
# lfs: false
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
- name: Checkout code
uses: actions/checkout@v3

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
ruby-version: 3.3.0
bundler-cache: true
username: ${{ secrets.KAMAL_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_KEY }}

- run: gem install kamal
- name: Set Tag
id: tag
run: |
echo "tag=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT
# - name: Setup kamal secrets file
# run: |
# mkdir -p .kamal
# touch .kamal/secrets
# echo "${{ secrets.KAMAL_REGISTRY_PASSWORD }}" > .kamal/secrets
# echo "${{ secrets.SV }}" > .kamal/secrets
# chmod 600 .kamal/secrets
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: true
labels: |
"service=telebugs"
tags: |
"${{ secrets.KAMAL_REGISTRY_USER }}/telebugs:latest"
"${{ secrets.KAMAL_REGISTRY_USER }}/telebugs:${{ steps.tag.outputs.tag }}"
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: webfactory/ssh-agent@v0.9.0
- uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- uses: docker/setup-buildx-action@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- run: kamal lock release
- name: Install kamal
run: gem install kamal

- run: kamal deploy
- name: Deploy
run: kamal deploy --skip-push
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
KAMAL_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_KEY }}

0 comments on commit cd3e27b

Please sign in to comment.