🐳 Update dockerfile #48
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: Build UI and publish to GitHub Container Registry | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build and push Docker image | |
run: | | |
docker login --username sambwagner --password ${{ secrets.GHCR_PAT }} ghcr.io | |
cd UI | |
docker build . -t ghcr.io/sambwagner/port-flow-ui:latest | |
docker push ghcr.io/sambwagner/port-flow-ui:latest | |
- name: Set up SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -H "${{ secrets.VPS_IP }}" >> ~/.ssh/known_hosts | |
- name: Deploy to VPS | |
run: | | |
ssh "${{ secrets.VPS_SSH_LOGIN }}" " | |
cd /var/www/port-flow && | |
docker pull ghcr.io/sambwagner/port-flow-ui:latest && | |
docker stop port-flow-ui || true && | |
docker rm port-flow-ui || true && | |
docker run -d --name port-flow-ui -p 3000:3000 ghcr.io/sambwagner/port-flow-ui:latest | |
" |