Fix ci #44
This file contains hidden or 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
| name: Deploy | |
| concurrency: | |
| group: production | |
| cancel-in-progress: true | |
| on: | |
| pull_request: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| scan_ruby: | |
| runs-on: ubuntu-latest | |
| env: | |
| RAILS_ENV: production | |
| RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Scan for common Rails security vulnerabilities using static analysis | |
| run: bin/brakeman --no-pager | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Lint code for consistent style | |
| run: bin/rubocop -f github | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install packages | |
| run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config google-chrome-stable | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Node.js dependencies | |
| run: npm install | |
| - name: Generate JS routes | |
| run: bin/rails js:routes | |
| - name: Build frontend assets | |
| run: bin/rails assets:precompile | |
| env: | |
| SECRET_KEY_BASE_DUMMY: 1 | |
| - name: Prepare database | |
| run: | | |
| bin/rails db:test:prepare | |
| - name: Run tests | |
| env: | |
| RAILS_ENV: test | |
| run: | | |
| bin/rails test | |
| deploy: | |
| needs: [scan_ruby, lint, test] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| timeout-minutes: 20 | |
| env: | |
| RAILS_ENV: production | |
| DOCKER_BUILDKIT: 1 | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up SSH agent | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: image=moby/buildkit:master | |
| - name: Setup Rails master key | |
| run: | | |
| echo "${{ secrets.RAILS_MASTER_KEY }}" > config/master.key | |
| chmod 600 config/master.key | |
| - name: Login to DigitalOcean Container Registry | |
| run: | | |
| echo "${{ secrets.DOCKER_REGISTRY_TOKEN }}" | docker login registry.digitalocean.com/super-registry -u ${{ secrets.DOCKER_REGISTRY_TOKEN }} --password-stdin | |
| - name: Kamal Deploy | |
| env: | |
| DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
| SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }} | |
| SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
| RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }} | |
| ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }} | |
| run: | | |
| bin/kamal lock release --verbose | |
| bin/kamal redeploy --verbose |