Update Capistrano deployment task #44
This file contains 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: Continuous Deployment | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Install yarn and build assets | |
run: | | |
yarn --frozen-lockfile | |
yarn build | |
yarn build:css | |
- name: Install psql | |
run: sudo apt-get -yqq install libpq-dev | |
- name: Build DB | |
env: | |
PGHOST: localhost | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
RAILS_ENV: test | |
run: bin/rails db:setup | |
- name: Run Tests | |
env: | |
PGHOST: localhost | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
RAILS_ENV: test | |
run: | | |
bundle exec rake test | |
bundle exec rake test:system | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: standardrb | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
uses: amoeba/standardrb-action@v2 | |
deploy: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
needs: [build-and-test, lint] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: akhileshns/[email protected] | |
with: | |
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | |
heroku_app_name: ${{secrets.HEROKU_APP_NAME}} | |
heroku_email: ${{secrets.HEROKU_EMAIL}} | |
- run: heroku run rails db:migrate |