Skip to content

Instantly share code, notes, and snippets.

@mscoutermarsh
Last active July 1, 2023 19:09
Show Gist options
  • Save mscoutermarsh/f618f6c72e021aee3b0c520070b6ca66 to your computer and use it in GitHub Desktop.
Save mscoutermarsh/f618f6c72e021aee3b0c520070b6ca66 to your computer and use it in GitHub Desktop.
GitHub Actions + PlanetScale example. Get DR number and deploy it.
steps:
- name: checkout
uses: actions/checkout@v3
- name: Setup pscale
uses: planetscale/setup-pscale-action@v1
- name: Get Deploy Requests
if: github.event.pull_request.merged == true
env:
PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }}
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}
run: |
pscale deploy-request list db-name --org orgname -f json > dr_output.txt
deploy_request_number=$(jq --arg branch ${{ github.head_ref }} '.[] | select(.state == "open" and .branch == $branch) | .number' dr_output.txt)
echo "DEPLOY_REQUEST_NUMBER=$deploy_request_number" >> $GITHUB_ENV
- name: Deploy schema migrations
if: ${{ env.DEPLOY_REQUEST_NUMBER }}
env:
PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }}
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}
run: |
pscale deploy-request deploy db-name ${{ env.DEPLOY_REQUEST_NUMBER }} --wait --org org-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment