Last active
July 16, 2020 22:52
-
-
Save noozo/d11531405d6714b8bdd0c1db41e4a8b5 to your computer and use it in GitHub Desktop.
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: Deploy | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
test_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Slack Notification (Start) | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.slack_bot_token }} | |
uses: pullreminders/slack-action@master | |
with: | |
args: '{\"channel\":\"@nocivus\",\"text\":\"Starting website deployment...\"}' | |
- name: Deploy To Linode | |
uses: appleboy/ssh-action@master | |
with: | |
host: pedroassuncao.com | |
username: xxxxx | |
key: ${{ secrets.ssh_key }} | |
port: 22 | |
script_stop: true | |
script: | | |
echo "Sourcing nvm..." | |
. /home/xxxxx/.nvm/nvm.sh | |
echo "Pulling code..." | |
cd noozo_v2/pedroassuncao.com | |
git submodule update --remote | |
git pull --recurse-submodules origin master | |
echo "Updating mix deps..." | |
mix deps.get --only prod | |
echo "Setting up secrets..." | |
rm config/prod.secret.server.exs | |
ln -s ~/prod.secret.exs config/prod.secret.server.exs | |
echo "Compiling..." | |
MIX_ENV=prod mix compile | |
echo "Setting up assets..." | |
npm install --prefix assets | |
npm run deploy --prefix assets | |
MIX_ENV=prod mix phx.digest | |
echo "Releasing..." | |
MIX_ENV=prod mix release --overwrite | |
MIX_ENV=prod mix ecto.migrate | |
echo "Stopping server..." | |
_build/prod/rel/noozo/bin/noozo stop | |
sleep 5 | |
echo "Starting server..." | |
_build/prod/rel/noozo/bin/noozo daemon | |
echo "All done." | |
- name: Slack Notification (Success) | |
if: success() | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.slack_bot_token }} | |
uses: pullreminders/slack-action@master | |
with: | |
args: '{\"channel\":\"@nocivus\",\"text\":\"Website successfuly deployed :rocket:\"}' | |
- name: Slack Notification (Fail) | |
if: failure() | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.slack_bot_token }} | |
uses: pullreminders/slack-action@master | |
with: | |
args: '{\"channel\":\"@nocivus\",\"text\":\"Website failed to deploy :dizzy_face:\"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment