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:
authorStefan Giehl <stefan@matomo.org>2020-02-12 10:41:03 +0300
committerGitHub <noreply@github.com>2020-02-12 10:41:03 +0300
commitb07e8cf272e4cf7d8926eca43851ded78214a192 (patch)
tree9d50f325e162e488e28544770742b232764ce78c /.github
parentcce28d09be27006a12654f5cc5aeff7927eb0618 (diff)
Adds action for building tracker js files (#15542)
This action will make it possible to automatically update the minified tracker js files. It is triggered with a comment "build js" within a Pull Request. It (currently) only works for Pull Requests that are based on a local branch.
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/buildtrackerjs.yml82
1 files changed, 82 insertions, 0 deletions
diff --git a/.github/workflows/buildtrackerjs.yml b/.github/workflows/buildtrackerjs.yml
new file mode 100644
index 0000000000..f8c60c6a28
--- /dev/null
+++ b/.github/workflows/buildtrackerjs.yml
@@ -0,0 +1,82 @@
+name: Build Tracker JS files
+
+on:
+ issue_comment:
+ types: [created]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Detect branch for PR
+ id: vars
+ run: |
+ PR=$( echo "${{ github.event.comment.issue_url }}" | grep -oE 'issues/([0-9]+)$' | cut -d'/' -f 2 )
+
+ 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 .base.repo.full_name)
+ STATE=$(echo "${PR_INFO}" | jq -r .state)
+
+ 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 0;
+ fi
+
+ echo ::set-output name=branch::$REF
+ - uses: actions/setup-java@v1
+ with:
+ java-version: 9
+ if: steps.vars.outputs.branch != ''
+ - uses: actions/checkout@v2
+ with:
+ ref: ${{ steps.vars.outputs.branch }}
+ lfs: false
+ if: steps.vars.outputs.branch != ''
+ - 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 != ''
+ - name: Fetch YUICompressor
+ run: |
+ cd $GITHUB_WORKSPACE/js
+ wget https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.zip
+ unzip yuicompressor-2.4.8.zip
+ if: steps.vars.outputs.branch != ''
+ - name: Build JS files
+ run: |
+ cd $GITHUB_WORKSPACE/js
+ sed '/<DEBUG>/,/<\/DEBUG>/d' < piwik.js | sed 's/eval/replacedEvilString/' | java -jar yuicompressor-2.4.8.jar --type js --line-break 1000 | sed 's/replacedEvilString/eval/' | sed 's/^[/][*]/\/*!/' > piwik.min.js && cp piwik.min.js ../piwik.js && cp piwik.min.js ../matomo.js
+ if: steps.vars.outputs.branch != ''
+ - name: Push changes
+ run: |
+ if [[ $( git diff --numstat ) ]]
+ then
+ cd $GITHUB_WORKSPACE
+ git add piwik.js matomo.js js/piwik.min.js
+ git commit -m "rebuilt piwik.js"
+ git push
+ fi
+ if: steps.vars.outputs.branch != ''