-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (62 loc) · 2.16 KB
/
copy-command.yml
File metadata and controls
72 lines (62 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Copy Production DB to Staging
run-name: Copy Production DB to Staging
concurrency:
group: copy-db-pr-${{ github.event.client_payload.slash_command.args.named.prId }}
cancel-in-progress: true
on:
repository_dispatch:
types: [copy-command]
workflow_dispatch:
inputs:
prId:
description: "PR to confirm success to"
required: true
permissions:
contents: read
pull-requests: write
statuses: write
jobs:
getPRHead:
name: Get PR head SHA
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.pr-head.outputs.result }}
steps:
- name: Get PR head SHA
id: pr-head
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const payload = context.payload;
const prId = payload.inputs ? payload.inputs.prId : payload.client_payload.slash_command.args.named.prId;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: parseInt(prId, 10)
});
return pr.head.sha;
copy:
name: Copy Production Database to Staging
runs-on: ubuntu-latest
needs: getPRHead
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ needs.getPRHead.outputs.sha }}
- name: Setup CI
uses: ./.github/composite/setup-ci
with:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up OpenJDK 25
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "25"
cache: "maven"
- name: Copy Production Database to Staging
run: bun run .github/scripts/copy-prod-db/index.ts --run-url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} --username=${{ github.event.client_payload.github.actor || github.actor }} --sha=${{ needs.getPRHead.outputs.sha }}
env:
PR_ID: ${{ github.event.client_payload.slash_command.args.named.prId || github.event.inputs.prId }}