Skip to content

Commit eee4a8b

Browse files
authored
Fix auto release flow (#488)
1 parent e367403 commit eee4a8b

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.github/workflows/major-upgrade.yml

+18-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
description: 'Increment on Moodle version to be checked, available: major, minor'
1010
default: minor
1111
dryrun:
12-
type: boolean
12+
type: string
1313
default: false
1414
secrets:
1515
RELEASE_BOT_APP_ID:
@@ -33,13 +33,10 @@ jobs:
3333
with:
3434
egress-policy: audit
3535

36-
- name: Generate release token
37-
id: generate_release_token
38-
uses: tibdex/github-app-token@v2
39-
with:
40-
app_id: ${{ secrets.RELEASE_BOT_APP_ID }}
41-
private_key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
42-
36+
- name: Debug
37+
run: |
38+
echo "dryrun: ${{ inputs.dryrun }}"
39+
4340
- name: Checkout code
4441
uses: actions/checkout@v4
4542

@@ -98,8 +95,9 @@ jobs:
9895
# Format Moodle version number
9996
TMP_REV=$(echo $next_version | rev)
10097
TMP_MINOR=$(echo $TMP_REV | cut -c -2 | rev | sed 's/^0*//')
98+
TMP_MINOR2=${TMP_MINOR:-0}
10199
TMP_MAJOR=$(echo $TMP_REV | cut -c 3- | rev)
102-
TMP_VERSION="$TMP_MAJOR.$TMP_MINOR"
100+
TMP_VERSION="$TMP_MAJOR.$TMP_MINOR2"
103101
104102
echo "$TARGET_BRANCH ($NEXT_COMMIT) exist, newer Moodle major/minor version is available"
105103
echo "ready=true" >> $GITHUB_OUTPUT
@@ -112,15 +110,15 @@ jobs:
112110
fi
113111
114112
- name: Branch old version
115-
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun == 'false'
113+
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun != 'true'
116114
uses: peterjgrainger/[email protected]
117115
env:
118116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119117
with:
120118
branch: ${{ steps.current_moodle.outputs.version }}
121119

122120
- name: Update source codes
123-
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun == 'false'
121+
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun != 'true'
124122
run: |
125123
export OLD_BRANCH=${{ steps.current_moodle.outputs.branch }}
126124
export OLD_COMMIT=${{ steps.current_moodle.outputs.commit }}
@@ -130,8 +128,16 @@ jobs:
130128
export NEW_VERSION=${{ steps.next_moodle.outputs.version }}
131129
./upgrade.sh
132130
131+
- name: Generate release token
132+
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun != 'true'
133+
id: generate_release_token
134+
uses: tibdex/github-app-token@v2
135+
with:
136+
app_id: ${{ secrets.RELEASE_BOT_APP_ID }}
137+
private_key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
138+
133139
- name: Create PR
134-
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun == 'false'
140+
if: steps.next_moodle.outputs.ready == 'true' && inputs.dryrun != 'true'
135141
uses: peter-evans/create-pull-request@v7
136142
with:
137143
token: ${{ steps.generate_release_token.outputs.token }}

.github/workflows/nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ jobs:
103103
RELEASE_BOT_PRIVATE_KEY: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
104104
with:
105105
version: ${{ matrix.trial }}
106-
dryrun: ${{ vars.DRYRUN == true }}
106+
dryrun: ${{ vars.DRYRUN }}

0 commit comments

Comments
 (0)