From 99dd009236d0ef35e5d826793fd7cf190b91493d Mon Sep 17 00:00:00 2001 From: asandikci Date: Fri, 15 Nov 2024 23:35:39 +0300 Subject: [PATCH] Update CI - Both build with/without drafts - publish to website branch without-draft build - deploy to actual website with-draft-build - remove _site directory while publishing to website branch to prevent caching/collisions - remove files in www/ directory in actual website to prevent caching/collisions --- .forgejo/workflows/build_and_test.yml | 41 ++++++++++++++++++++------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/build_and_test.yml b/.forgejo/workflows/build_and_test.yml index 515d4ed..6a972ee 100644 --- a/.forgejo/workflows/build_and_test.yml +++ b/.forgejo/workflows/build_and_test.yml @@ -1,4 +1,4 @@ -name: "Build and Deploy Test Version (with Drafts!) - next.asandikci.com" +name: "Build and Deploy Test Version (with/without Drafts) - next.asandikci.com" on: push: branches: @@ -20,7 +20,7 @@ concurrency: cancel-in-progress: true jobs: - build_deploy: + build-and-push-prod: runs-on: docker container: image: git.asandikci.com/docker-images/website_builder:latest @@ -34,16 +34,9 @@ jobs: run: | cd web bundle install - bundle exec jekyll b --drafts + bundle exec jekyll b env: JEKYLL_ENV: "production" - - - name: Test Site - run: | - cd web - bundle exec htmlproofer _site \ - \-\-disable-external \ - \-\-ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/" - name: Push to "website" branch run: | @@ -51,6 +44,7 @@ jobs: git clone https://git.asandikci.com/asandikci.com/web cd web git checkout website + rm -rfv ./_site/ cp -rfv ../../web/_site . git config --global user.name "Aliberk Sandıkçı (CI)" git config --global user.email git+ci@asandikci.com @@ -58,6 +52,32 @@ jobs: git commit --all --message "Updated! [CI]" git push https://asandikci:${{ secrets.PUSH_KEY }}@git.asandikci.com/asandikci.com/web + build-drafts-and-deploy: + runs-on: docker + container: + image: git.asandikci.com/docker-images/website_builder:latest + steps: + - name: Git Clone + run: | + git clone https://git.asandikci.com/asandikci.com/web + ls -la ./web + + - name: Build Site (with Drafts!) + run: | + cd web + bundle install + bundle exec jekyll b --drafts + env: + JEKYLL_ENV: "production" + + # TODO: WILL BE FIXED + # - name: Test Site + # run: | + # cd web + # bundle exec htmlproofer _site \ + # \-\-disable-external \ + # \-\-ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/" + - name: Checkout & Deploy run: | mkdir deploy && cd deploy @@ -68,6 +88,7 @@ jobs: echo '${{ secrets.SFTP_PASSWORD }}' > ~/.passwd chmod 0400 ~/.passwd sshpass -f ~/.passwd sftp -oBatchMode=no -o StrictHostKeyChecking=accept-new -b - ${{ secrets.SFTP_USERNAME }}@${{ vars.SFTP_HOST }} << ! + rm www/* put -r . www/ bye ! \ No newline at end of file