-
-
Notifications
You must be signed in to change notification settings - Fork 10
67 lines (56 loc) · 1.78 KB
/
deploy.yml
File metadata and controls
67 lines (56 loc) · 1.78 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
name: Deploy
on:
workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency:
group: deploy-pr
cancel-in-progress: false
jobs:
create-deploy-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create or update deploy PR
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
git fetch origin main beta
if [ -z "$(git log --oneline origin/main..origin/beta)" ]; then
echo "No commits to deploy from beta to main."
exit 0
fi
compare_url="${{ github.server_url }}/${{ github.repository }}/compare/main...beta"
recent_commits="$(git log --oneline --max-count=25 origin/main..origin/beta)"
existing_pr="$(gh pr list --base main --head beta --state open --json number --jq '.[0].number')"
body_file="$(mktemp)"
{
echo "## Summary"
echo
echo "Deploy the current \`beta\` branch to production by merging it into \`main\`."
echo
echo "Compare: ${compare_url}"
echo
echo "## Commits"
echo
echo "\`\`\`"
echo "${recent_commits}"
echo "\`\`\`"
} > "${body_file}"
if [ -n "${existing_pr}" ]; then
gh pr edit "${existing_pr}" \
--title "Deploy beta to production" \
--body-file "${body_file}"
echo "Updated existing deploy PR #${existing_pr}."
exit 0
fi
gh pr create \
--draft \
--base main \
--head beta \
--title "Deploy beta to production" \
--body-file "${body_file}"