11name : Moodle Plugin CI
22
3- on :
4- push :
5- pull_request :
6- branches :
7- - main
3+ on : [push, pull_request]
84
95jobs :
106 test :
@@ -127,31 +123,35 @@ jobs:
127123 - name : Mark cancelled jobs as failed
128124 if : ${{ cancelled() }}
129125 run : exit 1
130- release :
126+
127+ create_tag_and_release :
131128 runs-on : ubuntu-24.04
132129 needs : test
133- if : github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags/')
134-
130+ if : github.event_name == 'push' && contains(github.event.head_commit.message, 'Merge pull request')
131+ permissions :
132+ contents : write
135133 steps :
136- - name : Checkout Plugin
137- uses : actions/checkout@v4
134+ - uses : actions/checkout@v4
138135 with :
139136 path : stripepayment
140137
141- - name : Install Node.js (for Grunt)
142- uses : actions/setup-node@v3
138+ - uses : actions/setup-node@v3
143139 with :
144- node-version : ' 18'
140+ node-version : 18
141+
142+ - name : Configure Git
143+ run : |
144+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
145+ git config --global user.name "github-actions[bot]"
146+
147+ - name : Clear npm cache
148+ run : npm cache clean --force
145149
146150 - name : Install Moodle Node dependencies
147151 run : npm install
148152 working-directory : stripepayment
149153
150- - name : Build Grunt
151- run : npm run build
152- working-directory : stripepayment
153-
154- - name : Install Plugin Composer Dependencies
154+ - name : Install Composer Dependencies
155155 run : composer install --no-dev --prefer-dist --no-progress
156156 working-directory : stripepayment
157157
@@ -162,10 +162,18 @@ jobs:
162162 run : |
163163 zip -r release/stripepayment.zip stripepayment -x@stripepayment/exclude.lst
164164
165+ - name : Get version from package.json
166+ id : version
167+ run : echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
168+ working-directory : stripepayment
169+
165170 - name : Create GitHub Release
166171 uses : softprops/action-gh-release@v1
167172 with :
173+ tag_name : v${{ steps.version.outputs.version }}
168174 files : release/stripepayment.zip
169- generate_release_notes : true
175+ body : |
176+ This is the official release for version v${{ steps.version.outputs.version }}.
177+ Thank you for using our Moodle plugin!
170178 env :
171- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
179+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments