Merge pull request #466 from open-source-uc/dev #83
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: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
name: Build frontend (for Sentry source maps) | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: npm install | |
working-directory: frontend | |
- name: Build frontend | |
run: npm run build | |
working-directory: frontend | |
deploy-staging: | |
runs-on: ubuntu-latest | |
name: Deploy to staging | |
timeout-minutes: 15 | |
env: | |
MACHINE: mallastest # This is the staging server | |
steps: | |
- name: Setup Tailscale | |
uses: tailscale/github-action@main | |
with: | |
oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }} | |
oauth-secret: ${{ secrets.TAILSCALE_OAUTH_SECRET }} | |
version: 1.44.0 | |
tags: tag:planner-ci | |
- name: Add SSH key | |
env: | |
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }} | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
run: | | |
mkdir -p ~/.ssh | |
MACHINE_IP="$(tailscale ip -4 $MACHINE)" | |
ssh-keyscan $MACHINE_IP >> ~/.ssh/known_hosts | |
echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/key | |
chmod 600 ~/.ssh/key | |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
ssh-add ~/.ssh/key | |
- name: Deploy to server | |
env: | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
run: | | |
MACHINE_IP="$(tailscale ip -4 $MACHINE)" | |
USERHOST="planner@$MACHINE_IP" | |
ssh $USERHOST "cd /opt/planner && just deploy staging" |