From 80cbb58b6bd13e844147b66ff6c72ec134158a64 Mon Sep 17 00:00:00 2001 From: sinavir Date: Tue, 17 Dec 2024 21:55:42 +0100 Subject: [PATCH] feat: Deploy to S3 --- .forgejo/workflows/build-site.yaml | 38 ---------------------------- .forgejo/workflows/build.yaml | 25 +++++++++++++++++++ default.nix | 40 +++++++++++++++--------------- 3 files changed, 45 insertions(+), 58 deletions(-) delete mode 100644 .forgejo/workflows/build-site.yaml create mode 100644 .forgejo/workflows/build.yaml diff --git a/.forgejo/workflows/build-site.yaml b/.forgejo/workflows/build-site.yaml deleted file mode 100644 index 0387f9c..0000000 --- a/.forgejo/workflows/build-site.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: build site -on: - pull_request: - types: [opened, synchronize, edited, reopened] - branches: - - main - push: - branches: - - main - -jobs: - build_site: - runs-on: nix - steps: - - uses: actions/checkout@v3 - - name: Build the site - run: nix-build - - - name: Pushing site to pages branch - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - run: | - git switch -C pages - find . -mindepth 1 -maxdepth 1 ! -name '.domains' ! -name '.git' ! -name 'result' -exec rm -rf {} + - ls -a - cp -r result/* . - rm result - git add . - - git config user.name "DGNum Deploy" - git config user.email "tech@dgnum.eu" - - git commit --message "Deploy site" - git push --set-upstream origin pages --force - - - uses: actions/upload-artifact@v3 - with: - name: site - path: ./ diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..df88f5c --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,25 @@ +name: build configuration +on: + push: + branches: + - main + +jobs: + build: + runs-on: nix + steps: + - uses: actions/checkout@v3 + + - name: Build + run: nix-build + + - name: deploy + run: nix-shell -p awscli2 --run "aws s3 sync ./result/ s3://$BUCKET/ --delete --endpoint-url $URL" + env: + URL: "https://s3.dgnum.eu/" + BUCKET: pub.dgnum.eu + AWS_ACCESS_KEY_ID: ${{ secrets.KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_KEY }} + + + diff --git a/default.nix b/default.nix index aedb7d4..72627fd 100644 --- a/default.nix +++ b/default.nix @@ -51,29 +51,29 @@ let ]); in -{ - devShell = pkgs.mkShell { - packages = [ - (pkgs.callPackage "${sources.lon}/nix/packages/lon.nix" { }) - python3 - ]; +pkgs.stdenv.mkDerivation { + name = "dgnum-landing"; + version = "1.0.1"; + src = ./src; + + passthru = { + devShell = pkgs.mkShell { + packages = [ + (pkgs.callPackage "${sources.lon}/nix/packages/lon.nix" { }) + python3 + ]; + }; }; - package = pkgs.stdenv.mkDerivation { - name = "dgnum-landing"; - version = "1.0.1"; - src = ./src; + buildInputs = [ python3 ]; - buildInputs = [ python3 ]; + env.DATA_FILE = pkgs.writers.writeJSON "data.json" { inherit description links; }; - env.DATA_FILE = pkgs.writers.writeJSON "data.json" { inherit description links; }; + configurePhase = '' + export BUILD_DIR=$out + ''; - configurePhase = '' - export BUILD_DIR=$out - ''; - - buildPhase = '' - python3 build.py - ''; - }; + buildPhase = '' + python3 build.py + ''; }