File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy
2+
3+ on :
4+ workflow_dispatch :
5+
6+ permissions :
7+ contents : read
8+ pull-requests : write
9+
10+ concurrency :
11+ group : deploy-pr
12+ cancel-in-progress : false
13+
14+ jobs :
15+ create-deploy-pr :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0
21+
22+ - name : Create or update deploy PR
23+ env :
24+ GH_TOKEN : ${{ github.token }}
25+ run : |
26+ set -euo pipefail
27+
28+ git fetch origin main beta
29+
30+ if [ -z "$(git log --oneline origin/main..origin/beta)" ]; then
31+ echo "No commits to deploy from beta to main."
32+ exit 0
33+ fi
34+
35+ compare_url="${{ github.server_url }}/${{ github.repository }}/compare/main...beta"
36+ recent_commits="$(git log --oneline --max-count=25 origin/main..origin/beta)"
37+ existing_pr="$(gh pr list --base main --head beta --state open --json number --jq '.[0].number')"
38+ body_file="$(mktemp)"
39+
40+ {
41+ echo "## Summary"
42+ echo
43+ echo "Deploy the current \`beta\` branch to production by merging it into \`main\`."
44+ echo
45+ echo "Compare: ${compare_url}"
46+ echo
47+ echo "## Commits"
48+ echo
49+ echo "\`\`\`"
50+ echo "${recent_commits}"
51+ echo "\`\`\`"
52+ } > "${body_file}"
53+
54+ if [ -n "${existing_pr}" ]; then
55+ gh pr edit "${existing_pr}" \
56+ --title "Deploy beta to production" \
57+ --body-file "${body_file}"
58+ echo "Updated existing deploy PR #${existing_pr}."
59+ exit 0
60+ fi
61+
62+ gh pr create \
63+ --draft \
64+ --base main \
65+ --head beta \
66+ --title "Deploy beta to production" \
67+ --body-file "${body_file}"
You can’t perform that action at this time.
0 commit comments