diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..3891d59e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,46 @@ +name: deploy to production + +on: + push: + branches: + - ga-mrsk + +jobs: + build: + runs-on: ubuntu-latest + env: + MRSK_REGISTRY_PASSWORD: ${{ secrets.MRSK_REGISTRY_PASSWORD }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.0 + bundler-cache: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Install dependencies + run: gem install mrsk + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.MRSK_REGISTRY_PASSWORD }} + + - name: MRSK deploy + env: + RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} + MEILI_MASTER_KEY: ${{ secrets.MEILI_MASTER_KEY }} + RUBYVIDEO_GITHUB_TOKEN: ${{ secrets.RUBYVIDEO_GITHUB_TOKEN }} + APPSIGNAL_PUSH_API_KEY: ${{ secrets.APPSIGNAL_PUSH_API_KEY }} + run: mrsk deploy diff --git a/config/deploy.yml b/config/deploy.yml index c22a8ed8..fd108248 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -1,47 +1,28 @@ -# Name of your application. Used to uniquely configure containers. service: rubyvideo -# Name of the container image. image: adrienpoly/rubyvideo -# Deploy to these servers. servers: - 91.107.208.207 -# Credentials for your image host. registry: - # Specify the registry server, if you're not using Docker Hub - # server: registry.digitalocean.com / ghcr.io / ... username: adrienpoly - - # Always use an access token rather than real password when possible. password: - KAMAL_REGISTRY_PASSWORD -# Inject ENV variables into containers (secrets come from .env). env: clear: RUBY_YJIT_ENABLE: 1 + RAILS_ENV: production secret: - RAILS_MASTER_KEY - APPSIGNAL_PUSH_API_KEY - MEILI_MASTER_KEY - RUBYVIDEO_GITHUB_TOKEN -# Use a different ssh user than root ssh: user: root -# Configure builder setup. -# builder: -# args: -# RUBY_VERSION: 3.2.0 -# secrets: -# - GITHUB_TOKEN -# remote: -# arch: amd64 -# host: ssh://app@192.168.0.1 volumes: - "storage:/rails/storage" -# Use accessory services (secrets come from .env). accessories: search: image: getmeili/meilisearch:v1.1 @@ -60,40 +41,15 @@ accessories: - MEILI_MASTER_KEY volumes: - "storage:/rails/storage" - # files: - # - config/mysql/production.cnf:/etc/mysql/my.cnf - # - db/production.sql.erb:/docker-entrypoint-initdb.d/setup.sql - # directories: - # - data:/var/lib/mysql -# redis: -# image: redis:7.0 -# host: 192.168.0.2 -# port: 6379 -# directories: -# - data:/data -# Configure custom arguments for Traefik -# traefik: -# args: -# accesslog: true -# accesslog.format: json -# labels: -# traefik.tcp.routers.other.rule: "HostSNI(`*`)" -# traefik.tcp.routers.other.entrypoints: search -# traefik.tcp.services.other.loadbalancer.server.port: 7700 -# traefik: -# options: -# publish: -# - 80:80 -# - "7700:7700" -# args: -# entrypoints.web.address: ":80" -# entrypoints.otherentrypoint.address: ":7700" -# Configure a custom healthcheck (default is /up on port 3000) -# healthcheck: -# path: /healthz -# port: 4000 builder: cache: type: registry options: mode=max,image-manifest=true,oci-mediatypes=true +# builder: +# args: +# RUBY_VERSION: 3.2.0 +# RAILS_ENV: production +# NODE_VERSION: 19.12.0 +# YARN_VERSION: 1.22.19 +# multiarch: false