Bläddra i källkod

ci: extract postgres_password from .env in remote machine

Nicolas Meienberger 1 år sedan
förälder
incheckning
af5b5afab5
2 ändrade filer med 11 tillägg och 1 borttagningar
  1. 1 0
      .github/workflows/ci.yml
  2. 10 1
      .github/workflows/e2e.yml

+ 1 - 0
.github/workflows/ci.yml

@@ -9,6 +9,7 @@ env:
   APPS_REPO_ID: repo-id
   INTERNAL_IP: localhost
   REDIS_HOST: redis
+  REDIS_PASSWORD: redis
   APPS_REPO_URL: https://repo.github.com/
   DOMAIN: localhost
   LOCAL_DOMAIN: tipi.lan

+ 10 - 1
.github/workflows/e2e.yml

@@ -21,6 +21,7 @@ jobs:
     outputs:
       droplet_id: ${{ steps.create-droplet.outputs.droplet_id }}
       droplet_ip: ${{ steps.get-droplet-ip.outputs.droplet_ip }}
+      postgres_password: ${{ steps.get-postgres-password.outputs.postgres_password }}
 
     steps:
       - name: Checkout
@@ -94,6 +95,12 @@ jobs:
           user: root # TODO: use non-root user
           key: ${{ secrets.SSH_KEY }}
 
+      - name: Get POSTGRES_PASSWORD from .env file
+        id: get-postgres-password
+        run: |
+          postgres_password=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "cat ./runtipi/.env | grep POSTGRES_PASSWORD | cut -d '=' -f2")
+          echo "postgres_password=$postgres_password" >> $GITHUB_OUTPUT
+
   e2e:
     timeout-minutes: 30
     runs-on: ubuntu-latest
@@ -126,7 +133,9 @@ jobs:
           node-version: 18
 
       - name: Create .env.e2e file with Droplet IP
-        run: echo "SERVER_IP=${{ needs.deploy.outputs.droplet_ip }}" > .env.e2e
+        run: |
+          echo "SERVER_IP=${{ needs.deploy.outputs.droplet_ip }}" > .env.e2e
+          echo "POSTGRES_PASSWORD=${{ needs.deploy.outputs.postgres_password }}" >> .env.e2e
 
       - name: Install dependencies
         run: pnpm install