summaryrefslogtreecommitdiff
path: root/.github/workflows/checkversion.yml
blob: f1d76d48c8b4a37f861b6bd227e7995a782bb623 (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
name: Check for new version every hour

on:
  workflow_dispatch:
  repository_dispatch:
    types: on_demand

jobs:
  create_issue:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write
    steps:
      - name: Get downloadable version
        id: dlversion
        run: |
          RandNum=$((1 + $RANDOM % 5000))
          curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.$RandNum.212 Safari/537.36" -o $HOME/version.html https://net-secondary.web.minecraft-services.net/api/v1.0/download/links
          LatestURL=$(grep -o 'https://www.minecraft.net/bedrockdedicatedserver/bin-linux/[^"]*' $HOME/version.html)
          echo "::set-output name=downloadversion::$(echo "$LatestURL" | sed -e 's/.*server-//g' -e 's/.zip//')"

      - name: Get Release Notes
        id: dlversionnotes
        run: |
          RandNum=$((1 + $RANDOM % 5000))
          curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.$RandNum.212 Safari/537.36" -o $HOME/hc.html https://feedback.minecraft.net/api/v2/help_center/en-us/sections/360001186971/articles
          titleversion=$(echo "${{ steps.dlversion.outputs.downloadversion }}" | sed -r 's/([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)/\1-\2-\3/g')
          echo "::set-output name=downloadversionnotes::$(grep -o 'https://feedback.minecraft.net/hc/en-us/articles/[^"]*'${titleversion}'[^"]*' $HOME/hc.html)"

      - uses: actions/checkout@v3
        name: Checkout repo

      - name: Latest supported version from repo
        id: suppversion
        run: echo "::set-output name=supportversion::$(cat .github/assets/supportedVersion)"

      - uses: nickderobertis/check-if-issue-exists-action@master
        name: Check if Issue Exists
        id: check_if_issue_exists
        with:
          repo: Pugmatt/BedrockConnect
          token: ${{ secrets.GITHUB_TOKEN }}
          title: New Bedrock Version ${{ steps.dlversion.outputs.downloadversion }} has been published!
          labels: enhancement
      
      - name: Create an issue
        if: ${{ steps.check_if_issue_exists.outputs.exists == 'false' && steps.dlversion.outputs.downloadversion != steps.suppversion.outputs.supportversion }} 
        uses: actions-ecosystem/action-create-issue@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          title: New Bedrock Version ${{ steps.dlversion.outputs.downloadversion }} has been published!
          body: |
            ## New Bedrock Version ${{ steps.dlversion.outputs.downloadversion }}

            Release Notes: ${{ steps.dlversionnotes.outputs.downloadversionnotes }}

            - [X] Notify @Pugmatt @kmpoppe @Camotoy @CrafterPika
            - [ ] Update source code
            - [ ] Update [.github/assets/supportedVersion](../blob/master/.github/assets/supportedVersion) to the latest version

          labels: |
            enhancement