Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8630a98a3 | ||
|
|
79ab7a9b54 | ||
|
|
9ab7790110 | ||
|
|
0b3581e815 | ||
|
|
c027849a4d | ||
|
|
7644ffe486 | ||
|
|
1c5541d875 | ||
|
|
9090036f7f | ||
|
|
8edbb85903 | ||
|
|
b01ce005c6 | ||
|
|
597c76c2c9 | ||
|
|
81dcba3537 | ||
|
|
56a8e1675a | ||
|
|
f97d179cfb | ||
|
|
217fae3f6e | ||
|
|
ddb4c30d7c | ||
|
|
cff6a4d7d6 | ||
|
|
f3c2511291 | ||
|
|
04fa718a7c | ||
|
|
757d0f6f68 | ||
|
|
c0fd42b089 | ||
|
|
29678e4171 | ||
|
|
d5939a2184 | ||
|
|
901d4f5474 | ||
|
|
988d559a7f | ||
|
|
26cec94393 | ||
|
|
0e5df25eaa | ||
|
|
1da515163c | ||
|
|
c032ae55fe | ||
|
|
0e4ebab525 | ||
|
|
0f9245b6b2 | ||
|
|
e88dbe739d | ||
|
|
ed4954e7fc | ||
|
|
9fae826205 | ||
|
|
8ef49c55a6 | ||
|
|
126faeec80 | ||
|
|
bc2b94db6a | ||
|
|
cc42437e7f | ||
|
|
de2ecaf839 | ||
|
|
afc44ec968 | ||
|
|
baad5111d3 | ||
|
|
f62fa3608d | ||
|
|
1fe1bf1b6e | ||
|
|
7de176aa1a | ||
|
|
6c89dcc3c2 | ||
|
|
1fc9d0b8c9 | ||
|
|
ca90e94671 | ||
|
|
f19f9ba116 | ||
|
|
559df7506c | ||
|
|
6449fb2d67 | ||
|
|
d93138349b | ||
|
|
a06625b818 | ||
|
|
b2cb20b4a0 | ||
|
|
28e437469a | ||
|
|
df97385a82 | ||
|
|
e277c79fb3 | ||
|
|
5df36a724e | ||
|
|
553b5ee2b6 | ||
|
|
9ce291351f | ||
|
|
77c7738a08 | ||
|
|
9aea346b02 | ||
|
|
64fec3f4dc | ||
|
|
2f23b1bd75 | ||
|
|
ed3cd9867b | ||
|
|
db60419881 | ||
|
|
3f48bd817c | ||
|
|
58ad0d389a | ||
|
|
6a0f600276 | ||
|
|
716f9aa535 | ||
|
|
6cb8818377 | ||
|
|
dcef391438 | ||
|
|
4d5da7bd2c | ||
|
|
c2bd6da20e | ||
|
|
a309f7664a | ||
|
|
6176d24e9d | ||
|
|
ac0ccebfb4 | ||
|
|
1be2402216 | ||
|
|
d6f763748f | ||
|
|
304f32383f | ||
|
|
8c138a7485 |
@@ -1,15 +0,0 @@
|
||||
name: Hello world
|
||||
|
||||
on:
|
||||
- push
|
||||
|
||||
jobs:
|
||||
say-hello:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Print hello
|
||||
run: echo "Hello, world! from Gitea Actions"
|
||||
|
||||
@@ -8,11 +8,17 @@ on:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
|
||||
env:
|
||||
REMOTE_DEPLOY_PATH: /tmp/app # Change to your remote deploy base path
|
||||
# Base path for PR preview environments
|
||||
REMOTE_DEPLOY_PATH: /var/app/test/test
|
||||
|
||||
# --- CUSTOMIZABLE PRODUCTION PATH ---
|
||||
# Set the absolute path for your production deployment on the remote server.
|
||||
REMOTE_PROD_PATH: /var/app/test/test-prod
|
||||
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
SSH_PORT: ${{ secrets.SSH_PORT || 22 }} # Default to port 22 if not set
|
||||
SSH_PORT: ${{ secrets.SSH_PORT || 22 }}
|
||||
|
||||
jobs:
|
||||
prepare_deployment_vars:
|
||||
@@ -24,14 +30,18 @@ jobs:
|
||||
- name: Set deployment variables
|
||||
id: set-vars
|
||||
run: |
|
||||
REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
DEPLOY_DIR_NAME="pr-${{ github.event.pull_request.number }}"
|
||||
# For PRs, create a unique directory under the base path
|
||||
DEPLOY_PATH="${REMOTE_DEPLOY_PATH}/${REPO_NAME}-pr-${{ github.event.pull_request.number }}"
|
||||
else
|
||||
DEPLOY_DIR_NAME="main"
|
||||
# For 'main' branch, use the specified production path.
|
||||
# Fallback to a default if REMOTE_PROD_PATH is empty.
|
||||
DEPLOY_PATH="${REMOTE_PROD_PATH:-${REMOTE_DEPLOY_PATH}/main}"
|
||||
fi
|
||||
echo "DEPLOY_PATH=${REMOTE_DEPLOY_PATH}/${DEPLOY_DIR_NAME}" >> $GITHUB_ENV
|
||||
echo "deploy_path=${REMOTE_DEPLOY_PATH}/${DEPLOY_DIR_NAME}" >> $GITHUB_OUTPUT
|
||||
echo "DEPLOY_PATH will be: ${REMOTE_DEPLOY_PATH}/${DEPLOY_DIR_NAME}"
|
||||
echo "DEPLOY_PATH=${DEPLOY_PATH}" >> $GITHUB_ENV
|
||||
echo "deploy_path=${DEPLOY_PATH}" >> $GITHUB_OUTPUT
|
||||
echo "DEPLOY_PATH will be: ${DEPLOY_PATH}"
|
||||
|
||||
create_remote_directory:
|
||||
name: Create remote directory
|
||||
@@ -42,7 +52,7 @@ jobs:
|
||||
|| github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
uses: webfactory/ssh-agent@e83874834305fe9a4a2997156cb26c5de65a8555 # v0.10.0
|
||||
with:
|
||||
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
|
||||
|
||||
@@ -50,7 +60,6 @@ jobs:
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
echo "Scanning SSH host key for $SSH_HOST:$SSH_PORT..."
|
||||
ssh-keyscan -p "$SSH_PORT" -T 10 -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||
echo "::error::Failed to ssh-keyscan $SSH_HOST:$SSH_PORT"
|
||||
exit 1
|
||||
@@ -58,7 +67,7 @@ jobs:
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
- name: Create directory on remote
|
||||
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "mkdir -p ${{ needs.prepare_deployment_vars.outputs.deploy_path }}"
|
||||
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "mkdir -p '${{ needs.prepare_deployment_vars.outputs.deploy_path }}'"
|
||||
|
||||
sync_repo_files:
|
||||
name: Sync repository files
|
||||
@@ -68,10 +77,11 @@ jobs:
|
||||
(github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.merged == false)
|
||||
|| github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
|
||||
- name: Sync files via scp
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@7e85c2e09aa21988492acd66466b5d68bda49e2b # master
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
@@ -79,12 +89,6 @@ jobs:
|
||||
port: ${{ env.SSH_PORT }}
|
||||
source: "./"
|
||||
target: "${{ needs.prepare_deployment_vars.outputs.deploy_path }}"
|
||||
#target: "/tmp/app/main"
|
||||
# The 'exclude' parameter is supported and should be kept
|
||||
# exclude: |
|
||||
# .git/
|
||||
# .github/
|
||||
# node_modules/
|
||||
|
||||
run_docker_compose:
|
||||
name: Run docker-compose remotely
|
||||
@@ -95,7 +99,7 @@ jobs:
|
||||
|| github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
uses: webfactory/ssh-agent@e83874834305fe9a4a2997156cb26c5de65a8555 # v0.10.0
|
||||
with:
|
||||
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
|
||||
|
||||
@@ -103,7 +107,6 @@ jobs:
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
echo "Scanning SSH host key for $SSH_HOST:$SSH_PORT..."
|
||||
ssh-keyscan -p "$SSH_PORT" -T 10 -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||
echo "::error::Failed to ssh-keyscan $SSH_HOST:$SSH_PORT"
|
||||
exit 1
|
||||
@@ -111,18 +114,18 @@ jobs:
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
- name: Run docker-compose on remote host
|
||||
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd ${{ needs.prepare_deployment_vars.outputs.deploy_path }} && docker-compose up -d --build"
|
||||
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd '${{ needs.prepare_deployment_vars.outputs.deploy_path }}' && docker-compose up -d --build"
|
||||
|
||||
cleanup_mr_environment:
|
||||
name: Cleanup MR environment
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare_deployment_vars, prepare_deployment_vars]
|
||||
needs: prepare_deployment_vars
|
||||
if: |
|
||||
github.event_name == 'pull_request' &&
|
||||
(github.event.action == 'closed' || github.event.pull_request.merged == true)
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
uses: webfactory/ssh-agent@e83874834305fe9a4a2997156cb26c5de65a8555 # v0.10.0
|
||||
with:
|
||||
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
|
||||
|
||||
@@ -130,13 +133,15 @@ jobs:
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
echo "Scanning SSH host key for $SSH_HOST:$SSH_PORT..."
|
||||
ssh-keyscan -p "$SSH_PORT" -T 10 -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||
echo "::error::Failed to ssh-keyscan $SSH_HOST:$SSH_PORT"
|
||||
exit 1
|
||||
}
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
- name: Run docker-compose down on remote host
|
||||
run: ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "cd '${{ needs.prepare_deployment_vars.outputs.deploy_path }}' && docker-compose down"
|
||||
|
||||
- name: Delete deployment directory
|
||||
run: |
|
||||
ssh -p "$SSH_PORT" $SSH_USER@$SSH_HOST "if [ -d '${{ needs.prepare_deployment_vars.outputs.deploy_path }}' ]; then rm -rf '${{ needs.prepare_deployment_vars.outputs.deploy_path }}'; echo 'Directory removed.'; else echo 'Directory not found, skipping.'; fi"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
web:
|
||||
image: nginx:1.26.1-alpine3.19-slim
|
||||
image: nginx:1.31.6-alpine-slim@sha256:80149a0e5bc9fa0b8beaff5b8a453f71ba8ba038895d418381297ffa5cd57782
|
||||
ports:
|
||||
- "80"
|
||||
volumes:
|
||||
|
||||
+10
-1
@@ -2,5 +2,14 @@
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
],
|
||||
// "packageRules": [
|
||||
// {
|
||||
// "matchCategories": [
|
||||
// "docker"
|
||||
// ],
|
||||
// "pinDigests": true
|
||||
// }
|
||||
// ],
|
||||
"pinDigests": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user