improve coverage #4
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 to DigitalOcean | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:17 | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3.6' | |
| bundler-cache: true | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: | | |
| yarn install --frozen-lockfile | |
| - name: Setup test database | |
| env: | |
| RAILS_ENV: test | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/streamsource_test | |
| REDIS_URL: redis://localhost:6379/1 | |
| run: | | |
| bundle exec rails db:create | |
| bundle exec rails db:schema:load | |
| - name: Run tests | |
| env: | |
| RAILS_ENV: test | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/streamsource_test | |
| REDIS_URL: redis://localhost:6379/1 | |
| run: bundle exec rspec | |
| - name: Run security checks | |
| run: | | |
| bundle exec brakeman -q -w2 | |
| bundle exec bundler-audit --update | |
| deploy: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Deploy to DigitalOcean | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.DROPLET_HOST }} | |
| username: deploy | |
| key: ${{ secrets.DEPLOY_SSH_KEY }} | |
| script: | | |
| cd /var/www/streamsource | |
| ./deploy/github-deploy.sh | |
| - name: Health check | |
| run: | | |
| sleep 30 | |
| curl -f https://${{ secrets.DROPLET_HOST }}/health || exit 1 | |
| - name: Notify deployment status | |
| if: always() | |
| uses: 8398a7/action-slack@v3 | |
| with: | |
| status: ${{ job.status }} | |
| text: 'StreamSource deployment ${{ job.status }}' | |
| webhook_url: ${{ secrets.SLACK_WEBHOOK }} | |
| continue-on-error: true |