This commit is contained in:
73
.github/workflows/deploy.yml
vendored
73
.github/workflows/deploy.yml
vendored
@@ -4,72 +4,41 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: gitea.sashabayda.ca
|
|
||||||
IMAGE_NAME: ${{ gitea.repository }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ gitea.actor }}
|
|
||||||
password: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest
|
|
||||||
type=sha
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-and-push
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy to Remote Server
|
- name: Deploy to Windows Machine
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.REMOTE_HOST }}
|
host: ${{ secrets.REMOTE_HOST }}
|
||||||
username: ${{ secrets.REMOTE_USER }}
|
username: ${{ secrets.REMOTE_USER }}
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
script: |
|
script: |
|
||||||
# Login to registry
|
# Navigate to project directory or clone if it doesn't exist
|
||||||
echo ${{ secrets.GITEA_TOKEN }} | docker login gitea.sashabayda.ca -u ${{ gitea.actor }} --password-stdin
|
if (Test-Path "C:\projects\digital-resume-FE") {
|
||||||
|
cd C:\projects\digital-resume-FE
|
||||||
# Pull new image
|
git pull origin main
|
||||||
docker pull gitea.sashabayda.ca/${{ gitea.repository }}:latest
|
} else {
|
||||||
|
mkdir -p C:\projects
|
||||||
|
cd C:\projects
|
||||||
|
git clone https://gitea.sashabayda.ca/Bayda77/digital-resume-FE.git
|
||||||
|
cd digital-resume-FE
|
||||||
|
}
|
||||||
|
|
||||||
# Stop and remove existing container
|
# Stop and remove existing container
|
||||||
docker stop resume-frontend || true
|
docker stop resume-frontend 2>$null
|
||||||
docker rm resume-frontend || true
|
docker rm resume-frontend 2>$null
|
||||||
|
|
||||||
|
# Build the Docker image
|
||||||
|
docker build -t resume-frontend:latest .
|
||||||
|
|
||||||
# Run new container
|
# Run new container
|
||||||
docker run -d \
|
docker run -d `
|
||||||
--name resume-frontend \
|
--name resume-frontend `
|
||||||
--restart unless-stopped \
|
--restart unless-stopped `
|
||||||
-p 80:80 \
|
-p 3000:80 `
|
||||||
gitea.sashabayda.ca/${{ gitea.repository }}:latest
|
resume-frontend:latest
|
||||||
|
|
||||||
# Cleanup unused images
|
# Cleanup unused images
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
|
|||||||
Reference in New Issue
Block a user