diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-11-23 13:36:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 13:36:27 +0300 |
commit | 81c7fd643fb5042652767bf15c4ea75d053e9841 (patch) | |
tree | 48bb652142728f75bd13413c61a17503ed66862b /.github | |
parent | 5e61d020718f0dc551354633a881c0fb4a6a07ca (diff) |
Improve Vue Build action (#18369)
Currently when a build runs for an PR coming from a fork, the action fails.
This will change the process, so it succeeds if vue files are still up to date, or leave a PR comment if the files need to be updated
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/buildvue.yml | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/.github/workflows/buildvue.yml b/.github/workflows/buildvue.yml index 6f2bf0c738..fe4471b014 100644 --- a/.github/workflows/buildvue.yml +++ b/.github/workflows/buildvue.yml @@ -41,12 +41,7 @@ jobs: exit 0; fi - if [[ $BASE != $GITHUB_REPOSITORY ]] - then - echo "It's only possible to update local branches" - exit 1; - fi - + echo ::set-output name=islocalbranch::$BASE == $GITHUB_REPOSITORY echo ::set-output name=branch::$REF echo ::set-output name=base::$BASE_SHA - uses: actions/checkout@v2 @@ -64,7 +59,7 @@ jobs: if [[ $VUE_FILES_MODIFIED == "0" ]] then echo "No vue files modified" - exit; + exit 0; fi echo ::set-output name=vue_modified::1 @@ -126,12 +121,32 @@ jobs: run: php ./console vue:build if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1' - name: Push changes + id: push run: | if [[ $( git diff --numstat plugins/*/vue/dist/*.js ) ]] then - cd $GITHUB_WORKSPACE - git add plugins/*/vue/dist/*.js plugins/*/vue/dist/*.json - git commit -m "built vue files" - git push + if [[ ! ${{ steps.vars.outputs.islocalbranch }} ]] + then + echo "It's only possible to update local branches automatically. Adding a comment instead." + echo ::set-output name=failure::1 + else + cd $GITHUB_WORKSPACE + git add plugins/*/vue/dist/*.js plugins/*/vue/dist/*.json + git commit -m "built vue files" + git push + fi fi if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1' + - uses: actions/github-script@v5 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Vue files are not up to date. Please build the files using `./console vue:build` locally and push them to your branch.' + }) + if: steps.push.outputs.failure == '1' + - name: Fail if not up to date + run: exit 1 + if: steps.push.outputs.failure == '1' |