Skip to content

Commit

Permalink
Add CD script
Browse files Browse the repository at this point in the history
  • Loading branch information
Naught0 committed Aug 4, 2024
1 parent c25b3ed commit 496a377
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CD
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '21'
- name: SSH Setup
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/server.key
chmod 600 ~/.ssh/server.key
cat >>~/.ssh/config <<END
Host server
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/server.key
StrictHostKeyChecking no
END
apt-get update && apt-get install openssh-client
env:
SSH_USER: ${{ secrets.SERVER_SSH_USER }}
SSH_KEY: ${{ secrets.SERVER_SSH_KEY }}
SSH_HOST: ${{ secrets.SERVER_SSH_HOST }}
- name: Build
run: |
npm install -g pnpm
pnpm install
pnpm build
- name: Deploy
run: |
scp -r .next server:~/slackernews/.next
ssh server 'systemctl --user restart slackernews'

0 comments on commit 496a377

Please sign in to comment.