Skip to content

Commit

Permalink
Simplify neon setup (#80)
Browse files Browse the repository at this point in the history
* Simplify neon setup

Signed-off-by: Matteo Collina <[email protected]>

* fixup

Signed-off-by: Matteo Collina <[email protected]>

---------

Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina authored Sep 5, 2023
1 parent 9f0d178 commit d2245f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
28 changes: 2 additions & 26 deletions .github/workflows/cleanup-neon-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,12 @@ jobs:
uses: actions-ecosystem/[email protected]
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 }}
8 changes: 4 additions & 4 deletions .github/workflows/platformatic-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2245f4

Please sign in to comment.