Deploy Meteor App to Server #13
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
# The setup is made mostly hard by my idea of creating a dedicated "continuous integration" ssh key. I normally use one ssh | |
# key for everything, but i don't feel like putting the private key on the interwebz : | |
# - have "mup deploy" running correctly from your machine first (learn more http://meteor-up.com/getting-started.html) with your regular ssh key | |
# - create a new key pair for CI deploys, lets call it id_rsa_do, by running ssh-keygen (learn more https://is.gd/kJkcAP) | |
# - add the content of (~/.ssh/id_rsa_do) in your repository as the secret "SSH_KEY" (learn more about the ssh-key-action https://is.gd/Ux9OXY) | |
# - add the output of "ssh-keyscan -H [IP OF YOUR DO SERVER]" in your repository as the secret "KNOWN_HOSTS" (learn more https://is.gd/edNByI) | |
# - make sure your droplet accepts the new key pair, run cat ~/.ssh/id_rsa_do.pub | ssh root@[IP OF YOUR DO SERVER] "cat >> ~/.ssh/authorized_keys" ( learn more https://is.gd/Ufjpvq) | |
# - to make builds faster, list dev only dependencies as devDependencies in package.json ( learn more https://is.gd/0spDMp ) | |
# - add this file to your app, in the same folder as here (.github/workflows/main.yml) | |
# - change the last command of this script so that it finds your mup.js file | |
name: Deploy Meteor App to Server | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
environment: prod | |
steps: | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
# Test SSH connectivity (fail fast) | |
- name: Test ssh key to fail fast | |
run: ssh ${{ vars.SSH_USER }}@${{ vars.SSH_HOST }} -t "pwd" | |
- uses: actions/checkout@v2 | |
- name: Get production dependencies only | |
run: cd ./app && npm install --production | |
- name: (Hack) Remove malformed package | |
run: find ./app/node_modules -name malformed_package_json -type d -prune -exec rm -rf "{}" \; | |
- name: Install mup locally | |
run: npm install mup | |
- name: Install meteor | |
run: curl https://install.meteor.com/ | sh | |
- name: Bundle the app and upload to Hoster | |
run: cd ./deploy && npx mup deploy | |
env: | |
SSH_USER: ${{ vars.SSH_USER }} | |
SSH_HOST: ${{ vars.SSH_HOST }} | |
DOMAIN: ${{ vars.DOMAIN }} | |
PROXY_PORT: ${{ vars.PROXY_PORT }} |