test push #15
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 Next.js App | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Create config directory and config.json | |
run: | | |
mkdir -p ./src/config | |
echo "{\"server\": \"${{ secrets.CONFIG_SERVER }}\"}" > ./src/config/config.json | |
- name: Install dependencies | |
run: yarn install | |
- name: Build Next.js app | |
run: yarn build | |
- name: Create .ssh directory | |
run: mkdir -p ~/.ssh | |
- name: Add SSH key | |
run: | | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key | |
chmod 600 ~/.ssh/deploy_key | |
- name: Create known_hosts | |
run: ssh-keyscan -H ${{ secrets.REMOTE_HOST }} >> ~/.ssh/known_hosts | |
- name: Deploy to server | |
uses: easingthemes/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
TARGET: ${{ secrets.TARGET }} | |
with: | |
args: '-avz --delete' | |
source: 'public/' | |
target: ${{ secrets.TARGET }} |