Skip to content

Commit

Permalink
migrate(ci/cd): migrate builder contabo => linode
Browse files Browse the repository at this point in the history
  • Loading branch information
XHunter committed Dec 20, 2023
1 parent f349290 commit 71cc348
Showing 1 changed file with 20 additions and 51 deletions.
71 changes: 20 additions & 51 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,30 @@
# 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" ]
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}}
- uses: actions/checkout@v3
- name: Use Node.js 16.13.2
uses: actions/setup-node@v3
with:
node-version: 16.13.2

- 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}}
- name: Cleaning remote docker image and container
uses: fifsky/ssh-action@master
continue-on-error: true
with:
command: |
cd /root/portfolio/
git pull
docker build . -t koders-portfolio
docker rm $(docker stop $(docker ps -a -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/koders-portfolio --format="{{.ID}}")) &&
docker rmi koders-portfolio
docker run -d -p 8080:80 --name koders-portfolio koders-portfolio
host: ${{ secrets.REMOTE_HOST }}
user: ${{ secrets.REMOTE_USER }}
pass: ${{ secrets.REMOTE_PASSWORD}}

0 comments on commit 71cc348

Please sign in to comment.