name: Cache database between jobs description: "Cache or restore if necessary" inputs: DATABASE_URL: required: false default: "postgresql://postgres:postgres@localhost:5432/calendso" path: required: false default: "backups/backup.sql" runs: using: "composite" steps: - name: Generate cache key id: cache-key uses: ./.github/actions/cache-db-key with: path: ${{ inputs.path }} - name: Cache database id: cache-db uses: actions/cache@v4 env: DATABASE_URL: ${{ inputs.DATABASE_URL }} DATABASE_DIRECT_URL: ${{ inputs.DATABASE_URL }} E2E_TEST_CALCOM_QA_EMAIL: ${{ inputs.E2E_TEST_CALCOM_QA_EMAIL }} E2E_TEST_CALCOM_QA_PASSWORD: ${{ inputs.E2E_TEST_CALCOM_QA_PASSWORD }} E2E_TEST_CALCOM_QA_GCAL_CREDENTIALS: ${{ inputs.E2E_TEST_CALCOM_QA_GCAL_CREDENTIALS }} with: path: ${{ inputs.path }} key: ${{ steps.cache-key.outputs.key }} - run: yarn db-seed if: steps.cache-db.outputs.cache-hit != 'true' shell: bash - name: Postgres Dump Backup if: steps.cache-db.outputs.cache-hit != 'true' run: | mkdir -p $(dirname "${{ inputs.path }}") docker run --rm --network host \ -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} \ postgres:18 pg_dump "${{ inputs.DATABASE_URL }}" -O -f ${{ inputs.path }} shell: bash - name: Postgres Backup Restore if: steps.cache-db.outputs.cache-hit == 'true' run: | docker run --rm -i --network host \ -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} \ postgres:18 psql "${{ inputs.DATABASE_URL }}" -f ${{ inputs.path }} shell: bash