diff options
-rw-r--r-- | .github/workflows/submodules.yml | 86 | ||||
-rw-r--r-- | .github/workflows/translations.yml | 3 |
2 files changed, 88 insertions, 1 deletions
diff --git a/.github/workflows/submodules.yml b/.github/workflows/submodules.yml new file mode 100644 index 0000000000..25f4247923 --- /dev/null +++ b/.github/workflows/submodules.yml @@ -0,0 +1,86 @@ +name: Update Submodules + +on: + workflow_dispatch: + schedule: + - cron: "0 2 * * 5" + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: '4.x-dev' + lfs: false + - name: Prepare branches + 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" + + git remote add upstream https://github.com/matomo-org/matomo.git + + git push origin --delete submodules || true + git branch -D submodules || true + git fetch upstream 4.x-dev + git checkout -f upstream/4.x-dev + git branch submodules + git checkout -f submodules + - name: Checkout submodules + run: git submodule update --init --force + - name: Update all submodules + run: git submodule foreach "git checkout 4.x-dev || git checkout master; git pull --ff-only" + - name: Check for changes + id: changes + run: | + git submodule | grep -oE '^\+[0-9a-f]+ ([A-z\/\-]+)' | cut -d' ' -f 2 | xargs git add + IFS=$'\n' + changes=( $(git diff --staged --numstat | grep -oE '[A-z0-9\/\-]{2,}' ) ) + + # abort here if no change available + if [[ ${#changes[@]} -eq 0 ]] + then + exit 0 + fi + + message="Updated submodules:\n" + + for (( i=0; i < ${#changes[@]}; i++ )); do + message="$message- ${changes[$i]}\n" + done + + echo $message + + echo ::set-output name=message::$message + shell: bash + - name: Push changes + run: | + git commit -m "updates all submodules" + git push --set-upstream origin submodules + - name: Create PR + run: | + curl \ + --request POST \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "title":"[automatic submodule updates]", + "body":"${{ steps.changes.outputs.message }}", + "head":"submodules", + "base":"4.x-dev" + }' \ + --url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls + shell: bash + if: steps.changes.outputs.message diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index 8af2363e38..7e03f5de73 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -1,6 +1,7 @@ name: Translation Updates on: + workflow_dispatch: schedule: - cron: "0 2 * * 6" @@ -69,7 +70,7 @@ jobs: IFS=$'\n' changes=( $(git diff --numstat HEAD | grep -E '([0-9]+)\s+([0-9]+)\s+[a-zA-Z\/]*lang\/([a-z]{2,3}(-[a-z]{2,3})?)\.json' ) ) unset IFS - + # abort here if no change available if [[ ${#changes[@]} -eq 0 ]] then |