From 2e13456b2441da374566d55b4a8e1a2111641b83 Mon Sep 17 00:00:00 2001 From: nenzen Date: Thu, 22 May 2025 00:28:56 +0200 Subject: [PATCH 1/3] Add deployment of mocks --- .github/workflows/deploy-mocks.yml | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/deploy-mocks.yml diff --git a/.github/workflows/deploy-mocks.yml b/.github/workflows/deploy-mocks.yml new file mode 100644 index 0000000..dcd9bf2 --- /dev/null +++ b/.github/workflows/deploy-mocks.yml @@ -0,0 +1,54 @@ +name: Deploy Mocks to Server + +on: + push: + +jobs: + upload-mocks: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Detect changes in mocks/ + id: changes + run: | + git fetch --all --prune --unshallow || true + git log --oneline -n 5 || true + + echo "Checking for changes in mocks/..." + CHANGED=$(git diff --name-status origin/main...HEAD || true) + echo "Full diff output:" + echo "$CHANGED" + + MOCK_CHANGED=$(echo "$CHANGED" | grep -E '^[AMD]\s+mocks/' || true) + echo "Detected changes in mocks/:" + echo "$MOCK_CHANGED" + + { + echo "changed_files<> "$GITHUB_OUTPUT" + + + - name: Show changed_files output + run: echo "changed_files = '${{ steps.changes.outputs.changed_files }}'" + + - name: Install rsync + run: | + sudo apt-get update + sudo apt-get install -y rsync + + - name: Upload mocks via SSH + if: steps.changes.outputs.changed_files != '' + env: + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_KEY: ${{ secrets.MOCKER_AT_APIMPOSTER }} + run: | + echo "$SSH_KEY" > gitea_key.pem + chmod 600 gitea_key.pem + rsync -avz --delete --no-perms --no-times \ + -e "ssh -i gitea_key.pem -o StrictHostKeyChecking=no" \ + mocks/ $SSH_HOST:/data0/mocks/ -- 2.39.5 From 0cd7ee704f737ed3892fd918555dfaf3e318eb8a Mon Sep 17 00:00:00 2001 From: nenzen Date: Thu, 22 May 2025 00:31:05 +0200 Subject: [PATCH 2/3] Update mocks --- mocks/daisy/program.yaml | 135 --------------------------------------- mocks/test/test.yaml | 2 +- 2 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 mocks/daisy/program.yaml diff --git a/mocks/daisy/program.yaml b/mocks/daisy/program.yaml deleted file mode 100644 index 6c37caf..0000000 --- a/mocks/daisy/program.yaml +++ /dev/null @@ -1,135 +0,0 @@ -- method: "GET" - path: "/" - response: - status: 200 - headers: - Content-Type: "application/json" - body: - id: 12345 - name: ... - code: ... - name_en: ... - responsibleDepartment: - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - educationalInstitution: - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - type: MAGISTER - level: FIRST_CYCLE - - -- method: "GET" - path: "/{id}" - response: - status: 200 - headers: - Content-Type: "application/json" - body: - id: 12345 - name: ... - code: ... - name_en: ... - responsibleDepartment: - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - educationalInstitution: - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - - name_en: ... - id: 12345 - designation: ... - closed: true - name: ... - units: - - {} - - {} - type: MASTER - level: FIRST_CYCLE - -- method: "GET" - path: "/{id}/admissions" - response: - status: 500 - headers: - Content-Type: "application/json" - body: - - conditioned: false - kull: 12345 - discontinued: true - id: 12345 - studentId: 12345 - programId: 12345 - admissionSemester: 12345 diff --git a/mocks/test/test.yaml b/mocks/test/test.yaml index b839873..a91bf32 100644 --- a/mocks/test/test.yaml +++ b/mocks/test/test.yaml @@ -6,4 +6,4 @@ headers: Content-Type: "application/json" body: - name: "api test" + name: "api test 1" -- 2.39.5 From 5a843affdc2f96e3055d2a4494bff48e93bd160d Mon Sep 17 00:00:00 2001 From: nenzen Date: Thu, 22 May 2025 00:38:48 +0200 Subject: [PATCH 3/3] Run workflow on main only + rename ci.yml --- .github/workflows/{ci.yml => build.yml} | 0 .github/workflows/deploy-mocks.yml | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) rename .github/workflows/{ci.yml => build.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml diff --git a/.github/workflows/deploy-mocks.yml b/.github/workflows/deploy-mocks.yml index dcd9bf2..523c647 100644 --- a/.github/workflows/deploy-mocks.yml +++ b/.github/workflows/deploy-mocks.yml @@ -2,6 +2,7 @@ name: Deploy Mocks to Server on: push: + branches: [ main ] jobs: upload-mocks: @@ -14,11 +15,12 @@ jobs: - name: Detect changes in mocks/ id: changes run: | - git fetch --all --prune --unshallow || true + echo "Fetching history..." + git fetch --unshallow || true git log --oneline -n 5 || true echo "Checking for changes in mocks/..." - CHANGED=$(git diff --name-status origin/main...HEAD || true) + CHANGED=$(git diff --name-status HEAD~1 HEAD || true) echo "Full diff output:" echo "$CHANGED" @@ -32,7 +34,6 @@ jobs: echo "EOF" } >> "$GITHUB_OUTPUT" - - name: Show changed_files output run: echo "changed_files = '${{ steps.changes.outputs.changed_files }}'" -- 2.39.5