From f0511e210ba6f2e48aaa898ff299ab202c800ac5 Mon Sep 17 00:00:00 2001 From: Michael Buhler Date: Tue, 3 Dec 2024 21:25:07 +0700 Subject: [PATCH] ci: build and copy files to econosim.org closes #4 --- .github/workflows/build.yaml | 44 ++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 5 ++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .vscode/settings.json diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..da766ef --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,44 @@ +name: Build and Copy to Server + +on: + push: + branches: + - master + +jobs: + build-and-copy: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Node.js with caching + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: package-lock.json + - name: Configure SSH + env: + RSA_PRIVATE_KEY: ${{ secrets.SSH_RSA_PRIVATE_KEY }} + KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} + run: | + mkdir -p ~/.ssh + echo "$RSA_PRIVATE_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts + chmod 600 ~/.ssh/known_hosts + - name: Install npm dependencies + run: | + npm install + - name: Build the React app + run: | + npm run build + - name: Remove old files from the server + run: | + ssh econosim@econosim.org rm -frv /www/econosim.org/econosim.org/static + - name: Copy new files to the server + run: | + scp \ + -r \ + build/* \ + econosim@econosim.org:/www/econosim.org/econosim.org diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4e3d5fe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.autoSave": "onFocusChange", + "editor.formatOnPaste": true, + "editor.formatOnSave": true +} \ No newline at end of file