Skip to content

Migrate to Linode

Migrate to Linode #25

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build
on:
push:
branches: [ "main" ]
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.13.2
uses: actions/setup-node@v3
with:
node-version: 16.13.2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/koders-portfolio:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Cleaning remote docker image and container
uses: fifsky/ssh-action@master
continue-on-error: true
with:
command: |
docker rm $(docker stop $(docker ps -a -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/koders-portfolio --format="{{.ID}}")) &&
docker rmi ${{ secrets.DOCKER_HUB_USERNAME }}/koders-portfolio
host: ${{ secrets.HOST }}
user: ${{ secrets.USERNAME }}
pass: ${{ secrets.PASSWORD}}
port: ${{ secrets.PORT}}
- name: Building and deploying new website
uses: fifsky/ssh-action@master
with:
command: |
docker run -d -p 8080:80 --name koders-portfolio ${{ secrets.DOCKER_HUB_USERNAME }}/koders-portfolio
host: ${{ secrets.HOST }}
user: ${{ secrets.USERNAME }}
pass: ${{ secrets.PASSWORD}}
port: ${{ secrets.PORT}}