From 14b1292de50d2aa1be287e9306e7ffc248389f1f Mon Sep 17 00:00:00 2001 From: vorpax Date: Mon, 2 Feb 2026 10:41:56 +0100 Subject: [PATCH] update ci-cd --- .gitea/workflows/build-image.yml | 8 +++++ .github/workflows/build-deploy.yml | 57 ++++++++++++++++++++++++++++++ docker-compose.yml | 17 +++++---- 3 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build-deploy.yml diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml index 5af7561..2fbf137 100644 --- a/.gitea/workflows/build-image.yml +++ b/.gitea/workflows/build-image.yml @@ -44,3 +44,11 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + - name: Deploy stack + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: cd ~/ \ No newline at end of file diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 0000000..069c040 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,57 @@ +name: Build and Push Docker Image - HEC IA Wiki + +on: + push: + branches: + - main + - master + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha,prefix= + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'master') }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Deploy stack + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: git pull && docker compose pull && docker compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index b8929ee..1fc77d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,12 @@ services: app: - image: node:lts - ports: - - 4321:4321 - working_dir: /app - command: npm run dev -- --host 0.0.0.0 - volumes: - - ./:/app + build: . + restart: unless-stopped + expose: + - 80 + networks: + - public +networks: + public: + name: public + external: true \ No newline at end of file