This commit is contained in:
73
.github/workflows/deploy.yml
vendored
73
.github/workflows/deploy.yml
vendored
@@ -4,72 +4,41 @@ on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
REGISTRY: gitea.sashabayda.ca
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
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:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-push
|
||||
steps:
|
||||
- name: Deploy to Remote Server
|
||||
- name: Deploy to Windows Machine
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.REMOTE_HOST }}
|
||||
username: ${{ secrets.REMOTE_USER }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
# Login to registry
|
||||
echo ${{ secrets.GITEA_TOKEN }} | docker login gitea.sashabayda.ca -u ${{ gitea.actor }} --password-stdin
|
||||
|
||||
# Pull new image
|
||||
docker pull gitea.sashabayda.ca/${{ gitea.repository }}:latest
|
||||
# Navigate to project directory or clone if it doesn't exist
|
||||
if (Test-Path "C:\projects\digital-resume-FE") {
|
||||
cd C:\projects\digital-resume-FE
|
||||
git pull origin main
|
||||
} 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
|
||||
docker stop resume-frontend || true
|
||||
docker rm resume-frontend || true
|
||||
docker stop resume-frontend 2>$null
|
||||
docker rm resume-frontend 2>$null
|
||||
|
||||
# Build the Docker image
|
||||
docker build -t resume-frontend:latest .
|
||||
|
||||
# Run new container
|
||||
docker run -d \
|
||||
--name resume-frontend \
|
||||
--restart unless-stopped \
|
||||
-p 80:80 \
|
||||
gitea.sashabayda.ca/${{ gitea.repository }}:latest
|
||||
docker run -d `
|
||||
--name resume-frontend `
|
||||
--restart unless-stopped `
|
||||
-p 3000:80 `
|
||||
resume-frontend:latest
|
||||
|
||||
# Cleanup unused images
|
||||
docker image prune -f
|
||||
|
||||
Reference in New Issue
Block a user