aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/commands.yml
blob: 23636cff64c29882224e62764d61b0fb58017fdb (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Commands
on:
  issue_comment:
    types:
      - created
      - edited
  pull_request_target:
    types:
      - labeled
      - synchronize

permissions: {}
jobs:
  rebase:
    name: Rebase
    if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '@jellyfin-bot rebase') && github.event.comment.author_association == 'MEMBER'
    runs-on: ubuntu-latest
    steps:
      - name: Notify as seen
        uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          comment-id: ${{ github.event.comment.id }}
          reactions: '+1'

      - name: Checkout the latest code
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          fetch-depth: 0

      - name: Automatic Rebase
        uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
        env:
          GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}

  check-backport:
    permissions:
      contents: read

    name: Check Backport
    if: ${{ ( github.event.issue.pull_request && contains(github.event.comment.body, '@jellyfin-bot check backport') ) || github.event.label.name == 'stable backport' || contains(github.event.pull_request.labels.*.name, 'stable backport' ) }}
    runs-on: ubuntu-latest
    steps:
      - name: Notify as seen
        uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
        if: ${{ github.event.comment != null }}
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          comment-id: ${{ github.event.comment.id }}
          reactions: eyes

      - name: Checkout the latest code
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          fetch-depth: 0

      - name: Notify as running
        id: comment_running
        uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
        if: ${{ github.event.comment != null }}
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          issue-number: ${{ github.event.issue.number }}
          body: |
            Running backport tests...

      - name: Perform test backport
        id: run_tests
        run: |
          set +o errexit
          git config --global user.name "Jellyfin Bot"
          git config --global user.email "team@jellyfin.org"
          CURRENT_BRANCH="origin/${GITHUB_HEAD_REF}"
          git checkout master
          git merge --no-ff ${CURRENT_BRANCH}
          MERGE_COMMIT_HASH=$( git log -q -1 | head -1 | awk '{ print $2 }' )
          git fetch --all
          CURRENT_STABLE=$( git branch -r | grep 'origin/release' | sort -rV | head -1 | awk -F '/' '{ print $NF }' )
          stable_branch="Current stable release branch: ${CURRENT_STABLE}"
          echo ${stable_branch}
          echo ::set-output name=branch::${stable_branch}
          git checkout -t origin/${CURRENT_STABLE} -b ${CURRENT_STABLE}
          git cherry-pick -sx -m1 ${MERGE_COMMIT_HASH} &>output.txt
          retcode=$?
          cat output.txt | grep -v 'hint:'
          output="$( grep -v 'hint:'  output.txt )"
          output="${output//'%'/'%25'}"
          output="${output//$'\n'/'%0A'}"
          output="${output//$'\r'/'%0D'}" 
          echo ::set-output name=output::$output
          exit ${retcode}

      - name: Notify with result success
        uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
        if: ${{ github.event.comment != null && success() }}
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          comment-id: ${{ steps.comment_running.outputs.comment-id }}
          body: |
            ${{ steps.run_tests.outputs.branch }}
            Output from `git cherry-pick`:

            ---

            ${{ steps.run_tests.outputs.output }}
          reactions: hooray

      - name: Notify with result failure
        uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
        if: ${{ github.event.comment != null && failure() }}
        with:
          token: ${{ secrets.JF_BOT_TOKEN }}
          comment-id: ${{ steps.comment_running.outputs.comment-id }}
          body: |
            ${{ steps.run_tests.outputs.branch }}
            Output from `git cherry-pick`:

            ---

            ${{ steps.run_tests.outputs.output }}
          reactions: confused

  rename:
    name: Rename
    if: contains(github.event.comment.body, '@jellyfin-bot rename')
    runs-on: ubuntu-latest
    steps:
      - name: pull in script
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          repository: jellyfin/jellyfin-triage-script
      - name: install python
        uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
        with:
          python-version: '3.12'
          cache: 'pip'
      - name: install python packages
        run: pip install -r rename/requirements.txt
      - name: run rename script
        run: python3 rename.py
        working-directory: ./rename
        env:
          GH_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
          GH_REPO: ${{ github.repository }}
          ISSUE: ${{ github.event.issue.number }}
          COMMENT_ID: ${{ github.event.comment.id }}