From 05d6cf57b1ed09963cbcc4b4300ee82a628fb245 Mon Sep 17 00:00:00 2001 From: belajarqywok Date: Thu, 26 Sep 2024 18:10:21 +0700 Subject: [PATCH] Deploy WordPress on HuggingFace --- .github/workflows/pipelines.yaml | 51 ++++++++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 16 ++++++++++ README.md | 8 +++++ nginx.conf | 28 ++++++++++++++++++ start.sh | 4 +++ 6 files changed, 108 insertions(+) create mode 100644 .github/workflows/pipelines.yaml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 nginx.conf create mode 100644 start.sh diff --git a/.github/workflows/pipelines.yaml b/.github/workflows/pipelines.yaml new file mode 100644 index 0000000..7cbf08d --- /dev/null +++ b/.github/workflows/pipelines.yaml @@ -0,0 +1,51 @@ +name: pipeline + +on: + push: + branches: + - main + tags: + - '*' + +jobs: + + wordpress_deployment: + name: Wordpress Deployment + runs-on: ubuntu-latest + environment: Production + + env: + HF_TOKEN: ${{ secrets.HF_TOKEN }} + SPACE_NAME: wp-nginx-test + HF_USERNAME: qywok + + steps: + - name: Set global directory + run: git config --global --add safe.directory /github/workspace + + - uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 1000 + + - name: Check git status + run: git status + + - name: Configure git + run: | + git config --local user.email "alfariqyraihan@gmail.com" + git config --local user.name "qywok" + + - name: Pull changes from remote + run: | + git pull https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main || \ + (git merge --strategy-option theirs) + + - name: Add and commit changes + run: | + git add -A + git diff-index --quiet HEAD || git commit -m "Wordpress Deployment" + + - name: Push to Hugging Face + run: | + git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0bedf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +credentials \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3c0cd3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM php:7.4-fpm-alpine + +RUN apk --no-cache add nginx + +COPY nginx.conf /etc/nginx/nginx.conf + +RUN mkdir -p /run/nginx + +RUN mkdir -p /var/www/html && echo "" > /var/www/html/index.php + +EXPOSE 7860 + +COPY start.sh /start.sh +RUN chmod +x /start.sh + +CMD ["/start.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d238d0 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +--- +title: WordPress Testing +emoji: 🌐 +colorFrom: purple +colorTo: blue +sdk: docker +pinned: false +--- \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7e641be --- /dev/null +++ b/nginx.conf @@ -0,0 +1,28 @@ +events { + worker_connections 1024; +} + +http { + server { + listen 7860; + server_name localhost; + + root /var/www/html; + index index.php index.html; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ /\.ht { + deny all; + } + } +} diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..29d2afd --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +php-fpm & +nginx -g 'daemon off;'