fix: remove unused GITHUB_TOKEN and REPO_URL from deployment workflow
This commit is contained in:
@@ -8,6 +8,7 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
@@ -18,14 +19,25 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Log in to GHCR
|
||||||
|
run: echo "${{ github.token }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ghcr.io/mytheclipse/bete:latest
|
||||||
|
run: |
|
||||||
|
docker build -t "$IMAGE_NAME" .
|
||||||
|
docker push "$IMAGE_NAME"
|
||||||
|
|
||||||
- name: Deploy to VPS
|
- name: Deploy to VPS
|
||||||
env:
|
env:
|
||||||
VPS_HOST: ${{ secrets.VPS_HOST }}
|
VPS_HOST: ${{ secrets.VPS_HOST }}
|
||||||
VPS_USERNAME: ${{ secrets.VPS_USERNAME }}
|
VPS_USERNAME: ${{ secrets.VPS_USERNAME }}
|
||||||
VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
|
VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
|
||||||
ENV_FILE: ${{ secrets.ENV_FILE }}
|
ENV_FILE: ${{ secrets.ENV_FILE }}
|
||||||
REPO_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
GITHUB_ACTOR: ${{ github.actor }}
|
||||||
|
IMAGE_NAME: ghcr.io/mytheclipse/bete:latest
|
||||||
run: |
|
run: |
|
||||||
# 1. Setup SSH Key
|
# 1. Setup SSH Key
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -33,39 +45,24 @@ jobs:
|
|||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
ssh-keyscan -H "$VPS_HOST" >> ~/.ssh/known_hosts
|
ssh-keyscan -H "$VPS_HOST" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
# 2. Deploy using git clone and docker
|
# 2. Pull image and start containers on VPS
|
||||||
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no "$VPS_USERNAME@$VPS_HOST" "
|
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no "$VPS_USERNAME@$VPS_HOST" "
|
||||||
set -e
|
set -e
|
||||||
APP_DIR=/opt/imphenbot
|
APP_DIR=/opt/imphenbot
|
||||||
|
mkdir -p \$APP_DIR
|
||||||
# Configure git safe directory
|
cd \$APP_DIR
|
||||||
git config --global --add safe.directory \$APP_DIR
|
|
||||||
|
echo \"$GITHUB_TOKEN\" | docker login ghcr.io -u \"$GITHUB_ACTOR\" --password-stdin
|
||||||
# Configure git to use token for authentication
|
|
||||||
git config --global url.\"https://x-access-token:$GITHUB_TOKEN@github.com/\".insteadOf \"https://github.com/\"
|
printf '%s\nIMAGE_NAME=$IMAGE_NAME' \"$ENV_FILE\" > .env
|
||||||
|
|
||||||
# Clone or update repository
|
|
||||||
if [ -d \"\$APP_DIR/.git\" ]; then
|
|
||||||
echo 'Repository exists, pulling latest changes...'
|
|
||||||
cd \$APP_DIR
|
|
||||||
git fetch origin master
|
|
||||||
git reset --hard origin/master
|
|
||||||
else
|
|
||||||
echo 'Cloning repository...'
|
|
||||||
mkdir -p \$APP_DIR
|
|
||||||
git clone -b master --depth 1 $REPO_URL \$APP_DIR
|
|
||||||
cd \$APP_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Inject environment variables
|
|
||||||
echo \"$ENV_FILE\" > .env
|
|
||||||
|
|
||||||
# Build and start containers with docker compose
|
|
||||||
if command -v docker-compose &> /dev/null; then
|
if command -v docker-compose &> /dev/null; then
|
||||||
docker-compose down || true
|
docker-compose down || true
|
||||||
docker-compose up -d --build
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
else
|
else
|
||||||
docker compose down || true
|
docker compose down || true
|
||||||
docker compose up -d --build
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
fi
|
fi
|
||||||
"
|
"
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ version: '3.8'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: .
|
image: ${IMAGE_NAME:-ghcr.io/mytheclipse/bete:latest}
|
||||||
container_name: imphenbot-app
|
container_name: imphenbot-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user