-
Notifications
You must be signed in to change notification settings - Fork 1.3k
72 lines (66 loc) · 2.78 KB
/
automated-version-update-pr.yml
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
on:
workflow_dispatch:
inputs:
gutenbergMobileVersion:
required: true
title:
required: false
prURL:
required: false
body:
required: false
jobs:
create-pull-request:
runs-on: ubuntu-latest
env:
GUTENBERG_MOBILE_VERSION: ${{ github.event.inputs.gutenbergMobileVersion }}
PR_TITLE: ${{ github.event.inputs.title || format('Automated gutenberg-mobile version update for {0} !', github.event.inputs.gutenbergMobileVersion ) }}
PR_BODY: ${{ github.event.inputs.body || format('This PR incorporates changes from {0}.', github.event.inputs.prURL ) }}
GUTENBERG_MOBILE_PR_URL: ${{ github.event.inputs.prURL }}
steps:
- name: Create PR Description
run: |
PR_DESCRIPTION=$(cat << EOF
## Description
$PR_BODY
Related Gutenberg Mobile Pr: $GUTENBERG_MOBILE_PR_URL
EOF
)
PR_DESCRIPTION="${PR_DESCRIPTION//'%'/'%25'}"
PR_DESCRIPTION="${PR_DESCRIPTION//$'\n'/'%0A'}"
PR_DESCRIPTION="${PR_DESCRIPTION//$'\r'/'%0D'}"
echo "::set-output name=description::$PR_DESCRIPTION"
id: pr_description
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update Gutenberg Mobile Version
run: |
sed -i "s/gutenbergMobileVersion = '.*'/gutenbergMobileVersion = '$GUTENBERG_MOBILE_VERSION'/g" build.gradle
- name: Compute vars
id: vars
run: |
# Check if the version contains a "-" character
if [[ $GUTENBERG_MOBILE_VERSION == *"-"* ]]; then
# Get the substring up to "-" which should be either "trunk" or the PR number
VERSION_PREFIX=$(echo $GUTENBERG_MOBILE_VERSION | cut -d'-' -f1)
if [[ "$VERSION_PREFIX" == "trunk" ]]; then
echo ::set-output name=branch_name::update-gb-mobile-version/for-trunk-update
else
echo ::set-output name=branch_name::update-gb-mobile-version/for-pr-$VERSION_PREFIX
fi
else
# If the version doesn't contain a "-", it should be a tag
echo ::set-output name=branch_name::update-gb-mobile-version/for-tag-$GUTENBERG_MOBILE_VERSION
fi
echo ::set-output name=title::"$PR_TITLE"
echo ::set-output name=commit_message::"Update gutenbergMobileVersion to $GUTENBERG_MOBILE_VERSION"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: ${{ steps.vars.outputs.commit_message }}
title: ${{ steps.vars.outputs.title }}
branch: ${{ steps.vars.outputs.branch_name }}
labels: gutenberg-mobile
body: ${{ steps.pr_description.outputs.description }}
delete-branch: true