Tournament: start working on Prizes #393
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: Test and Deploy | |
on: | |
# pull_request: | |
# types: [opened, synchronize, reopened] | |
# branches: | |
# - 'main' | |
# - 'staging' | |
push: | |
jobs: | |
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@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Install PostgreSQL client | |
run: | | |
sudo apt-get -yqq install libpq-dev | |
- name: Build App | |
env: | |
PGHOST: localhost | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
RAILS_ENV: test | |
RAILS_MASTER_KEY: ${{ secrets.TEST_MASTER_KEY }} | |
run: | | |
bin/rails db:setup | |
yarn install | |
yarn build | |
bundle exec rake assets:precompile | |
- name: Run Tests | |
env: | |
PGHOST: localhost | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
RAILS_ENV: test | |
RAILS_MASTER_KEY: ${{ secrets.TEST_MASTER_KEY }} | |
run: | | |
bundle exec rspec | |
- name: Fix code coverage paths | |
working-directory: ./coverage | |
run: | | |
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.json | |
- name: SonarCloud Scan | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.SONAR_GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
deploy_production: | |
concurrency: | |
group: production_deploy | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: [test] | |
steps: | |
- name: Clone | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Push to dokku production | |
uses: dokku/github-action@master | |
with: | |
git_push_flags: '--force' | |
git_remote_url: 'ssh://[email protected]/free-dom' | |
ssh_host_key: ${{ secrets.DOKKU_PROD_HOST_KEY }} | |
ssh_private_key: ${{ secrets.DOKKU_PROD_PRIVATE_KEY }} | |
- name: Discord notification | |
if: "!contains(github.event.head_commit.message, '[skip discord]')" | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
DISCORD_EMBEDS: '[{"title": "Good news! FreeDom has been deployed to production.", "description": ${{ toJSON(github.event.head_commit.message) }}}]' | |
uses: Ilshidur/action-discord@master |