Repopulate Redis upon deploy #42
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: main | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
rubygems: latest | |
bundler-cache: true | |
- name: Run RSpec | |
run: bundle exec rake spec | |
- name: Run RuboCop | |
run: bundle exec rake rubocop | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} | |
- name: Connect and update | |
run: | | |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -p${{ secrets.SSH_PORT }} \ | |
"cd ${{ secrets.SSH_WORKING_DIR }} && \ | |
git fetch --prune && \ | |
git reset --hard @{upstream} && \ | |
git clean -d --force && \ | |
bundle install && \ | |
sudo systemctl restart rubies && \ | |
bundle exec rake redis" |