Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/delete-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Delete Preview

on:
pull_request:
types: [ closed ]

jobs:
closed:
runs-on: ubuntu-latest
steps:
- name: delete preview app
uses: digitalocean/app_action/delete@v2
with:
from_pr_preview: "true"
ignore_not_found: "true"
token: ${{ secrets.DIGITAL_OCEAN_API_TOKEN }}
64 changes: 64 additions & 0 deletions .github/workflows/deploy-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: App Platform Preview

on:
pull_request:
branches: [main]

permissions:
contents: read
pull-requests: write

jobs:
test:
name: preview
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Deploy the app
id: deploy
uses: digitalocean/app_action/deploy@v2
with:
deploy_pr_preview: "true"
token: ${{ secrets.DIGITAL_OCEAN_API_TOKEN }}
app_name: "openprescribing-hospitals"
- uses: actions/github-script@v7
env:
BUILD_LOGS: ${{ steps.deploy.outputs.build_logs }}
DEPLOY_LOGS: ${{ steps.deploy.outputs.deploy_logs }}
with:
script: |
const { BUILD_LOGS, DEPLOY_LOGS } = process.env
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀🚀🚀 The app was successfully deployed at ${{ fromJson(steps.deploy.outputs.app).live_url }}. [1]`
})
- uses: actions/github-script@v7
if: failure()
env:
BUILD_LOGS: ${{ steps.deploy.outputs.build_logs }}
DEPLOY_LOGS: ${{ steps.deploy.outputs.deploy_logs }}
with:
script: |
const { BUILD_LOGS, DEPLOY_LOGS } = process.env
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `The app failed to be deployed. Logs can be found [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
## Logs
<details>
<summary>Build logs</summary> [2]
\`\\
${BUILD_LOGS}
\`\\
</details>
<details>
<summary>Deploy logs</summary> [3]
\`\\
${DEPLOY_LOGS}
\`\\
</details>`
})
Loading