Co-authored-by: Thanh Quy - wolf <524H0124@student.tdtu.edu.vn> Co-authored-by: Thanh Quy- wolf <524H0124@student.tdtu.edu.vn> Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #29 Co-authored-by: TaNguyenThanhQuy <tanguyenthanhquy@noreply.localhost> Co-committed-by: TaNguyenThanhQuy <tanguyenthanhquy@noreply.localhost>
This commit was merged in pull request #29.
This commit is contained in:
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -22,15 +22,6 @@ jobs:
|
||||
id-token: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Calculate and Export Target IP
|
||||
run: |
|
||||
# 1. Lấy IP hiện tại và tính toán IP đích (đổi octet cuối thành .1)
|
||||
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
||||
CALCULATED_IP=$(echo $RUNNER_IP | cut -d'.' -f1-3).1
|
||||
|
||||
# 2. Đưa vào biến môi trường toàn cục của Job
|
||||
echo "TARGET_IP=${CALCULATED_IP}" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup SSH Key
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -38,33 +29,17 @@ jobs:
|
||||
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
|
||||
ssh-keyscan -p 222 -t ed25519 $TARGET_IP >> ~/.ssh/known_hosts
|
||||
ssh-keyscan -t ed25519 vps.demonkernel.io.vn >> ~/.ssh/known_hosts
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: latest
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/package.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
cache: true
|
||||
|
||||
- name: Update dependencies
|
||||
run: pnpm update
|
||||
@@ -80,7 +55,7 @@ jobs:
|
||||
GITEA_USER: ${{ github.actor }}
|
||||
GITEA_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
run: pnpm release
|
||||
|
||||
|
||||
- name: Set Version Output
|
||||
id: set_output
|
||||
run: |
|
||||
@@ -92,7 +67,7 @@ jobs:
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.demonkernel.io.vn
|
||||
registry: vps.demonkernel.io.vn
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
@@ -102,10 +77,10 @@ jobs:
|
||||
run: |
|
||||
# Lowercase Repository
|
||||
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
|
||||
RAW_VERSION="${{ steps.set_output.outputs.version }}"
|
||||
VERSION_LOWER=$(echo "$RAW_VERSION" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
|
||||
echo "repo=$REPO_LOWER" >> $GITHUB_OUTPUT
|
||||
echo "version=$VERSION_LOWER" >> $GITHUB_OUTPUT
|
||||
|
||||
@@ -120,15 +95,14 @@ jobs:
|
||||
git.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.version }}
|
||||
|
||||
- name: Commit & Push Changes
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
if [ -n "$(git status --porcelain)" ]&& [ "${{ github.ref_name }}" = "main" ]; then
|
||||
git config --global user.name "gitea-actions"
|
||||
git config --global user.email "actions-user@noreply.git.demonkernel.io.vn"
|
||||
|
||||
REPO_NAME="${{ gitea.repository }}"
|
||||
|
||||
git remote set-url origin ssh://git@$TARGET_IP:222/${REPO_NAME}.git
|
||||
git remote set-url origin ssh://git@vps.demonkernel.io.vn/${REPO_NAME}.git
|
||||
|
||||
git rm -r --cached .
|
||||
git add .
|
||||
@@ -136,4 +110,3 @@ jobs:
|
||||
|
||||
git push
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user