summaryrefslogtreecommitdiffstats
path: root/.github/workflows/update-nextcloud-ocp.yml
blob: a3945d5e54f0c6aa3e4e8bb996ca0806950bc134 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization

name: Update nextcloud/ocp

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

jobs:
  update-nextcloud-ocp:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        branches: ['main', 'master', 'stable28', 'stable27', 'stable26']

    name: update-nextcloud-ocp-${{ matrix.branches }}

    steps:
      - id: checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          ref: ${{ matrix.branches }}
          submodules: true
        continue-on-error: true

      - name: Set up php8.2
        if: steps.checkout.outcome == 'success'
        uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # v2
        with:
          php-version: 8.2
          # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
          extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
          coverage: none
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Read codeowners
        if: steps.checkout.outcome == 'success'
        id: codeowners
        run: |
          grep '/appinfo/info.xml' .github/CODEOWNERS | cut -f 2- -d ' ' | xargs | awk '{ print "codeowners="$0 }' >> $GITHUB_OUTPUT
        continue-on-error: true

      - name: Composer install
        if: steps.checkout.outcome == 'success'
        run: composer install

      - name: Composer update nextcloud/ocp
        id: update_branch
        if: ${{ steps.checkout.outcome == 'success' && matrix.branches != 'main' }}
        run: composer require --dev nextcloud/ocp:dev-${{ matrix.branches }}

      - name: Raise on issue on failure
        uses: dacbd/create-issue-action@ba4d1c45cccf9c483f2720cefb40e437f0ee6f7d # v1.2.1
        if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_branch.conclusion == 'failure' }}
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          title: Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}
          body: Please check the output of the GitHub action and manually resolve the issues<br>${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}<br>${{ steps.codeowners.outputs.codeowners }}

      - name: Composer update nextcloud/ocp
        id: update_main
        if: ${{ steps.checkout.outcome == 'success' && matrix.branches == 'main' }}
        run: composer require --dev nextcloud/ocp:dev-master

      - name: Raise on issue on failure
        uses: dacbd/create-issue-action@ba4d1c45cccf9c483f2720cefb40e437f0ee6f7d # v1.2.1
        if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_main.conclusion == 'failure' }}
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          title: Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}
          body: Please check the output of the GitHub action and manually resolve the issues<br>${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}<br>${{ steps.codeowners.outputs.codeowners }}

      - name: Reset checkout 3rdparty
        if: steps.checkout.outcome == 'success'
        run: |
          git clean -f 3rdparty
          git checkout 3rdparty
        continue-on-error: true

      - name: Reset checkout vendor
        if: steps.checkout.outcome == 'success'
        run: |
          git clean -f vendor
          git checkout vendor
        continue-on-error: true

      - name: Reset checkout vendor-bin
        if: steps.checkout.outcome == 'success'
        run: |
          git clean -f vendor-bin
          git checkout vendor-bin
        continue-on-error: true

      - name: Create Pull Request
        if: steps.checkout.outcome == 'success'
        uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v3
        with:
          token: ${{ secrets.COMMAND_BOT_PAT }}
          commit-message: "chore(dev-deps): Bump nextcloud/ocp package"
          committer: GitHub <noreply@github.com>
          author: nextcloud-command <nextcloud-command@users.noreply.github.com>
          signoff: true
          branch: automated/noid/${{ matrix.branches }}-update-nextcloud-ocp
          title: "[${{ matrix.branches }}] Update nextcloud/ocp dependency"
          body: |
            Auto-generated update of [nextcloud/ocp](https://github.com/nextcloud-deps/ocp/) dependency
          labels: |
            dependencies
            3. to review