From d2245f4f8f77917d62440a62a646a3ae03718d34 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 5 Sep 2023 14:42:57 +0200 Subject: [PATCH] Simplify neon setup (#80) * Simplify neon setup Signed-off-by: Matteo Collina * fixup Signed-off-by: Matteo Collina --------- Signed-off-by: Matteo Collina --- .github/workflows/cleanup-neon-branch.yml | 28 ++-------------------- .github/workflows/platformatic-preview.yml | 8 +++---- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/.github/workflows/cleanup-neon-branch.yml b/.github/workflows/cleanup-neon-branch.yml index 15bae2d..8e0a67b 100644 --- a/.github/workflows/cleanup-neon-branch.yml +++ b/.github/workflows/cleanup-neon-branch.yml @@ -15,36 +15,12 @@ jobs: uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1 with: github_token: ${{secrets.GITHUB_TOKEN}} - - run: | echo ${{ steps.get-pr-info.outputs.number}} - - name: Get last commit SHA - id: get_sha - run: | - echo "sha=${{ github.event.before }}" >> $GITHUB_OUTPUT - - name: Search branch by name - if: ${{ steps.get-pr-info-outputs.number }} != '' - id: get_branch_id - run: | - branch_id=$(curl --silent \ - "https://console.neon.tech/api/v2/projects/${PROJECT_ID}/branches" \ - --header "Accept: application/json" \ - --header "Content-Type: application/json" \ - --header "Authorization: Bearer ${API_KEY}" \ - | jq -r .branches \ - | jq -c '.[] | select(.name | contains("'${SHA}'")) .id' \ - | jq -r \ - ) \ - - echo "branch=${branch_id}" >> $GITHUB_OUTPUT - env: - PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} - API_KEY: ${{ secrets.NEON_API_KEY }} - SHA: ${{ steps.get_sha.outputs.sha }} - name: Delete Neon Branch - if: ${{ steps.get-pr-info-outputs.number }} != '' + if: ${{ steps.get-pr-info.outputs.number }} != '' uses: neondatabase/delete-branch-action@v3 with: project_id: ${{ secrets.NEON_PROJECT_ID }} - branch: ${{ steps.get_branch_id.outputs.branch }} + branch: pr-${{ steps.get-pr-info.outputs.number }} api_key: ${{ secrets.NEON_API_KEY }} diff --git a/.github/workflows/platformatic-preview.yml b/.github/workflows/platformatic-preview.yml index df75340..66ff390 100644 --- a/.github/workflows/platformatic-preview.yml +++ b/.github/workflows/platformatic-preview.yml @@ -23,13 +23,13 @@ jobs: - name: Get PR number id: get_pull_number run: | - pull_sha=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH") - echo "pull_sha=${pull_sha}" >> $GITHUB_OUTPUT - echo $pull_sha + pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") + echo "pull_number=${pull_number}" >> $GITHUB_OUTPUT + echo $pull_number - uses: neondatabase/create-branch-action@v4 with: project_id: ${{ secrets.NEON_PROJECT_ID }} - branch_name: ${{ steps.get_pull_number.outputs.pull_sha }} + branch_name: pr-${{ steps.get_pull_number.outputs.pull_number }} api_key: ${{ secrets.NEON_API_KEY }} id: create-branch - name: Deploy project