Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordizzy <diosmosis@users.noreply.github.com>2021-10-20 23:15:27 +0300
committerGitHub <noreply@github.com>2021-10-20 23:15:27 +0300
commit56f885d77c0e511b9948f495eef40e4e0512a9b0 (patch)
tree7a99f64446a9630e195bcd3f95e22c338394b1f7 /.github
parent073fbfc8efa1fd579acfd08026e820fb527e3582 (diff)
[Vue] Adding a "build vue" github action to build vue files (#18080)
* first attempt at a "build vue" github action * get build vue action to work * tweak file changed check * apply review feedback * do not error when no vue files modified * check HEAD^ for files not just local * Update buildvue.yml * Update buildvue.yml * Update buildvue.yml * Update buildvue.yml * try something else * debugging the action * trying again * skip steps if no vue files modified another way * more debugging * more debugging * more debugging * trying something new * refine + a test * remove echo + test * more tests * more tests * more tests * more tests * fix reference * fix reference * fix reference (really this time) * built vue files * undo test change * built vue files
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/buildvue.yml137
1 files changed, 137 insertions, 0 deletions
diff --git a/.github/workflows/buildvue.yml b/.github/workflows/buildvue.yml
new file mode 100644
index 0000000000..48b072652b
--- /dev/null
+++ b/.github/workflows/buildvue.yml
@@ -0,0 +1,137 @@
+name: Build Vue files
+
+on:
+ pull_request:
+ types: [synchronize]
+
+permissions:
+ actions: read
+ checks: none
+ contents: write
+ deployments: none
+ issues: read
+ packages: none
+ pull-requests: write
+ repository-projects: none
+ security-events: none
+ statuses: none
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Detect branch for PR
+ id: vars
+ run: |
+ PR="${{ github.event.pull_request.number }}"
+
+ PR_INFO=$( curl \
+ --request GET \
+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
+ --header 'content-type: application/json' \
+ --url https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR )
+ REF=$(echo "${PR_INFO}" | jq -r .head.ref)
+ BASE=$(echo "${PR_INFO}" | jq -r .head.repo.full_name)
+ STATE=$(echo "${PR_INFO}" | jq -r .state)
+ BASE_SHA=$(echo "${PR_INFO}" | jq -r .base.sha)
+
+ if [[ $STATE == "closed" ]]
+ then
+ echo "Pull Request already closed."
+ exit 0;
+ fi
+
+ if [[ $BASE != $GITHUB_REPOSITORY ]]
+ then
+ echo "It's only possible to update local branches"
+ exit 1;
+ fi
+
+ echo ::set-output name=branch::$REF
+ echo ::set-output name=base::$BASE_SHA
+ - uses: actions/checkout@v2
+ with:
+ ref: ${{ steps.vars.outputs.branch }}
+ lfs: false
+ if: steps.vars.outputs.branch != ''
+ - name: Check vue changes
+ id: vuecheck
+ run: |
+ git fetch --depth=1 origin ${{ steps.vars.outputs.base }}
+
+ VUE_FILES_MODIFIED=$(git diff --name-only ${{ steps.vars.outputs.base }} -- plugins/*/vue/**/* | wc -l)
+
+ if [[ $VUE_FILES_MODIFIED == "0" ]]
+ then
+ echo "No vue files modified"
+ exit;
+ fi
+
+ echo ::set-output name=vue_modified::1
+ if: steps.vars.outputs.branch != ''
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.0'
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: '16'
+ cache: 'npm'
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - run: npm install
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Get composer cache directory
+ id: composer-cache
+ run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Cache dependencies
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
+ restore-keys: ${{ runner.os }}-composer-
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Install dependencies
+ run: composer install --prefer-dist
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Quick Matomo Install
+ run: |
+ cat <<-EOF > ./config/config.ini.php
+ [General]
+ always_load_commands_from_plugin=CoreVue
+
+ [Development]
+ enabled = 1
+ EOF
+
+ cat ./config/config.ini.php
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Prepare git config
+ run: |
+ cat <<- EOF > $HOME/.netrc
+ machine github.com
+ login $GITHUB_ACTOR
+ password $GITHUB_TOKEN
+ machine api.github.com
+ login $GITHUB_ACTOR
+ password $GITHUB_TOKEN
+ EOF
+ chmod 600 $HOME/.netrc
+ git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
+ git config --global user.name "$GITHUB_ACTOR"
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Build Vue Modules
+ run: php ./console vue:build
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'
+ - name: Push changes
+ run: |
+ if [[ $( git diff --numstat plugins/*/vue/dist/*.js plugins/*/vue/dist/*.map ) ]]
+ then
+ cd $GITHUB_WORKSPACE
+ git add plugins/*/vue/dist/*.js plugins/*/vue/dist/*.map
+ git commit -m "built vue files"
+ git push
+ fi
+ if: steps.vars.outputs.branch != '' && steps.vuecheck.outputs.vue_modified == '1'