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

submodules.yml « workflows « .github - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ca5832020051ed5effbbdb2f1012df9f7f34b57a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Update Submodules

on:
  workflow_dispatch:
  schedule:
  - cron: "0 2 * * 5"

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:
    - uses: actions/checkout@v2
      with:
        ref: '5.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 5.x-dev
          git checkout -f upstream/5.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 5.x-dev || git checkout master; git pull --ff-only"
    - name: Check for changes
      id: changes
      continue-on-error: true
      run: |
          git submodule | grep -oE '^\+[0-9a-f]+ ([A-z\/\-]+)' | cut -d' ' -f 2 | xargs -r git add
          IFS=$'\n'
          changes=( $(git diff --staged --numstat | grep -oE '[A-z0-9\/\-]{2,}' || true ) )
          unset IFS

          # 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
      shell: bash
      if: steps.changes.outputs.message
    - 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":"5.x-dev"
                  }' \
                 --url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls
      shell: bash
      if: steps.changes.outputs.message