56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
name: Deploy Storybook
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: storybook-deployment
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Prepare SSH credentials
|
|
env:
|
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
DEPLOY_KNOWN_HOSTS: ${{ vars.DEPLOY_KNOWN_HOSTS }}
|
|
run: |
|
|
install -d -m 700 "$HOME/.ssh"
|
|
printf '%s\n' "$DEPLOY_SSH_KEY" > "$HOME/.ssh/deploy_key"
|
|
chmod 600 "$HOME/.ssh/deploy_key"
|
|
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$HOME/.ssh/deploy_known_hosts"
|
|
chmod 600 "$HOME/.ssh/deploy_known_hosts"
|
|
|
|
- name: Update checkout and deploy on host
|
|
env:
|
|
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
|
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
|
|
DEPLOY_PORT: ${{ vars.DEPLOY_PORT }}
|
|
run: |
|
|
test -n "$DEPLOY_HOST"
|
|
test -n "$DEPLOY_USER"
|
|
test -n "$DEPLOY_PATH"
|
|
test -n "$DEPLOY_PORT"
|
|
DEPLOY_PATH_B64="$(printf '%s' "$DEPLOY_PATH" | base64 | tr -d '\n')"
|
|
ssh \
|
|
-i "$HOME/.ssh/deploy_key" \
|
|
-p "$DEPLOY_PORT" \
|
|
-o BatchMode=yes \
|
|
-o StrictHostKeyChecking=yes \
|
|
-o UserKnownHostsFile="$HOME/.ssh/deploy_known_hosts" \
|
|
"$DEPLOY_USER@$DEPLOY_HOST" \
|
|
"DEPLOY_PATH_B64=$DEPLOY_PATH_B64 bash -se" <<'REMOTE'
|
|
set -euo pipefail
|
|
DEPLOY_PATH="$(printf '%s' "$DEPLOY_PATH_B64" | base64 -d)"
|
|
cd "$DEPLOY_PATH"
|
|
git fetch origin main
|
|
git checkout main
|
|
git pull --ff-only origin main
|
|
docker compose down && STORYBOOK_PORT=6024 docker compose up -d --build
|
|
REMOTE
|