Introduce cascading deletes for batches and certificates #183
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: "deploy-preview" | |
# yamllint disable-line rule:truthy | |
on: | |
# onl run this workflow on pull request events | |
pull_request | |
jobs: | |
review_app: | |
runs-on: ubuntu-latest | |
environment: | |
name: preview | |
url: https://pre-${{ github.event.pull_request.number }}.utum-certs.dpschool.app | |
concurrency: preview | |
# only run when a pull request is opened | |
#if: github.event_name == 'pull_request' && github.event.action == 'opened' | |
steps: | |
- name: Cloning repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Push to dokku | |
uses: dokku/github-action@master | |
with: | |
branch: "main" | |
# create a review app | |
command: review-apps:create | |
git_remote_url: "ssh://dokku@167.235.152.70:22/certificates" | |
git_push_flags: --force | |
# specify a name for the review app | |
review_app_name: pre-${{ github.event.pull_request.number }} | |
ssh_private_key: ${{ secrets.SSH_KEY_SIR }} | |
- name: Configure SSH | |
# see https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_KEY" > ~/.ssh/preview.key | |
chmod 600 ~/.ssh/preview.key | |
cat >>~/.ssh/config <<END | |
Host preview | |
HostName $SSH_HOST | |
User $SSH_USER | |
IdentityFile ~/.ssh/preview.key | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_USER: dokku | |
SSH_KEY: ${{ secrets.SSH_KEY_SIR }} | |
SSH_HOST: 167.235.152.70 | |
- name: Clone database | |
if: github.event_name == 'pull_request' && ( github.event.action == 'opened' || github.event.action == 'reopened' ) | |
# see https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ | |
run: | | |
ssh -t preview "postgres:clone certificates-db ${REVIEW_APP_NAME}-db" | |
ssh -t preview "postgres:unlink certificates-db ${REVIEW_APP_NAME} --no-restart" | |
ssh -t preview "postgres:link ${REVIEW_APP_NAME}-db $REVIEW_APP_NAME" | |
# ssh -t preview "postgres:promote ${REVIEW_APP_NAME}-db $REVIEW_APP_NAME" | |
env: | |
REVIEW_APP_NAME: pre-${{ github.event.pull_request.number }} | |
- name: Run database migrations | |
# see https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ | |
run: | | |
ssh -t preview "run $REVIEW_APP_NAME npx prisma migrate deploy" | |
env: | |
REVIEW_APP_NAME: pre-${{ github.event.pull_request.number }} | |
- name: Enable LetsEncrypt | |
if: github.event_name == 'pull_request' && ( github.event.action == 'opened' || github.event.action == 'reopened' ) | |
# see https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ | |
run: | | |
ssh -t preview "domains:set $REVIEW_APP_NAME $REVIEW_APP_NAME.utum-certs.dpschool.app" | |
ssh -t preview "letsencrypt:set $REVIEW_APP_NAME email $REVIEW_APP_EMAIL" | |
ssh -t preview "letsencrypt:enable $REVIEW_APP_NAME" | |
env: | |
REVIEW_APP_NAME: pre-${{ github.event.pull_request.number }} | |
REVIEW_APP_EMAIL: marcus@dpschool.io |