Skip to content

Merge pull request #40 from ituk-ttu/synnipaev-react #75

Merge pull request #40 from ituk-ttu/synnipaev-react

Merge pull request #40 from ituk-ttu/synnipaev-react #75

Workflow file for this run

name: Node.js CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create .env
run: echo "${{ secrets.ENV_FILE }}" > .env
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '22.13.1' # Adjust to the appropriate Node.js version
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_RSA }}
known_hosts: unnecessary
- name: Adding Known Hosts
run: ssh-keyscan -H ituk.ee >> ~/.ssh/known_hosts
- name: Build
run: docker build -t nextjs-ituk-ee .
- name: Stop old container
run: ssh [email protected] 'docker rm $(docker stop $(docker ps -a -q --filter ancestor=nextjs-ituk-ee --format="{{.ID}}")) || echo Failed to stop old container!'
- name: Push container to server
run: docker save nextjs-ituk-ee | ssh -C [email protected] docker load
- name: Start new container
run: ssh [email protected] "docker run -d -p 6969:3000 nextjs-ituk-ee || echo Failed to start new container!"
- name: Cleanup SSH keys
run: rm ~/.ssh/id_rsa