-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
66 lines (60 loc) · 2.18 KB
/
Copy pathaction.yml
File metadata and controls
66 lines (60 loc) · 2.18 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
name: 'Git PR Release'
description: 'Create a release pull request from staging branch to production branch using git-pr-release'
author: 'buffett-code-dev'
inputs:
github-token:
description: 'GitHub token with pull request write permissions'
required: true
branch-production:
description: 'Production branch name'
required: true
branch-staging:
description: 'Staging branch name'
required: true
labels:
description: 'Comma-separated labels to add to the release PR'
required: false
default: 'release'
template:
description: 'Path to the ERB template file for the release PR body'
required: false
runs:
using: 'composite'
steps:
- name: Check for diff between branches
id: check-diff
shell: bash
run: |
git fetch origin ${{ inputs.branch-production }} ${{ inputs.branch-staging }}
DIFF_COUNT=$(git rev-list --count origin/${{ inputs.branch-production }}..origin/${{ inputs.branch-staging }})
echo "diff_count=$DIFF_COUNT" >> "$GITHUB_OUTPUT"
if [ "$DIFF_COUNT" -eq 0 ]; then
echo "No diff between ${{ inputs.branch-production }} and ${{ inputs.branch-staging }}. Skipping."
else
echo "Found $DIFF_COUNT commit(s) to release."
fi
- name: Setup Ruby
if: ${{ steps.check-diff.outputs.diff_count != '0' }}
uses: ruby/setup-ruby@v1.321.0
with:
ruby-version: '3.4'
- name: Install git-pr-release
if: ${{ steps.check-diff.outputs.diff_count != '0' }}
shell: bash
run: gem install --no-document git-pr-release
- name: Set template path
if: ${{ inputs.template != '' }}
shell: bash
run: echo "GIT_PR_RELEASE_TEMPLATE=${TEMPLATE}" >> "$GITHUB_ENV"
env:
TEMPLATE: ${{ inputs.template }}
- name: Create release PR
if: ${{ steps.check-diff.outputs.diff_count != '0' }}
shell: bash
run: git-pr-release
env:
GIT_PR_RELEASE_TOKEN: ${{ inputs.github-token }}
GIT_PR_RELEASE_BRANCH_PRODUCTION: ${{ inputs.branch-production }}
GIT_PR_RELEASE_BRANCH_STAGING: ${{ inputs.branch-staging }}
GIT_PR_RELEASE_LABELS: ${{ inputs.labels }}
TZ: Asia/Tokyo