name: Deploy

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: Deploy to Heroku
    runs-on: ubuntu-20.04
    if: github.repository == 'freeCodeCamp/devdocs'
    steps:
    - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
    - name: Set up Ruby
      uses: ruby/setup-ruby@904f3fef85a9c80a3750cbe7d5159268fd5caa9f # v1.145.0
      with:
        bundler-cache: true # runs 'bundle install' and caches installed gems automatically
    - name: Run tests
      run: bundle exec rake
    - name: Deploy to Heroku
      uses: akhileshns/heroku-deploy@5ef17ff17a3fb8e9ad822ae6a61648a3ef9e0c3d # v3.12.13
      with:
        heroku_api_key: ${{secrets.HEROKU_API_KEY}}
        heroku_app_name: "devdocs"
        heroku_email: "team@freecodecamp.com"
        dontuseforce: true # --force should never be necessary
        dontautocreate: true # The app exists, it should not be created