@@ -3,50 +3,28 @@ name: Deploy Content
33on :
44 push :
55 branches : [main]
6- pull_request :
6+ pull_request_target :
77 types : [opened, reopened, synchronize, closed]
88
99concurrency :
1010 group : deploy-content-${{ github.ref }}
1111
1212env :
1313 STAGE : ${{ github.ref == 'refs/heads/main' && 'prod' || format('pr-{0}', github.event.number) }}
14+ COMMAND : ${{ github.event_name == 'pull_request_target' && github.event.action == 'closed' && 'destroy' || 'deploy' }}
15+ SHA : ${{ github.event.pull_request.head.sha || github.sha }}
1416
1517jobs :
16- deploy :
18+ deploy-or-destroy :
1719 if : ${{ github.event.action != 'closed' }}
1820 runs-on : ubuntu-latest
1921 permissions :
2022 contents : read
2123 pull-requests : write
2224 steps :
2325 - uses : actions/checkout@v4
24-
25- - uses : pnpm/action-setup@v4
26-
27- - uses : actions/setup-node@v5
2826 with :
29- node-version : 22
30- cache : pnpm
31-
32- - run : pnpm i
33-
34- - run : cd apps/content && pnpm alchemy deploy --stage ${{ env.STAGE }}
35- env :
36- ALCHEMY_STATE_TOKEN : ${{ secrets.ALCHEMY_STATE_TOKEN }}
37- CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
38- PULL_REQUEST : ${{ github.event.number }}
39- GITHUB_SHA : ${{ github.sha }}
40- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41-
42- cleanup :
43- runs-on : ubuntu-latest
44- if : ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
45- permissions :
46- contents : read
47- pull-requests : write
48- steps :
49- - uses : actions/checkout@v4
27+ ref : ${{ env.SHA }}
5028
5129 - uses : pnpm/action-setup@v4
5230
@@ -57,10 +35,10 @@ jobs:
5735
5836 - run : pnpm i
5937
60- - run : cd apps/content && pnpm alchemy destroy --stage ${{ env.STAGE }}
38+ - run : cd apps/content && pnpm alchemy ${{ env.COMMAND }} --stage ${{ env.STAGE }}
6139 env :
6240 ALCHEMY_STATE_TOKEN : ${{ secrets.ALCHEMY_STATE_TOKEN }}
6341 CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
6442 PULL_REQUEST : ${{ github.event.number }}
65- GITHUB_SHA : ${{ github.sha }}
43+ GITHUB_SHA : ${{ env.SHA }}
6644 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments