aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/generate-constants.yaml
blob: c5f667bad3a7e212d84fa7ad31b5e23b71dc34b0 (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
# Read the Javadoc of RepoPatternDump for more info

name: RepoPattern

env:
    data_repo: nea89o/SkyHanni-REPO

on:
    push:
    workflow_dispatch:

permissions: { }

jobs:
    regexes:
        runs-on: ubuntu-latest
        name: "Generate regexes"
        steps:
            -   uses: actions/checkout@v3
            -   name: Set up JDK 17
                uses: actions/setup-java@v3
                with:
                    java-version: 17
                    distribution: temurin
                    cache: gradle
            -   name: Setup gradle
                uses: gradle/gradle-build-action@v2
            -   name: Generate Repo Patterns using Gradle
                run: |
                    ./gradlew generateRepoPatterns --stacktrace
            -   uses: actions/upload-artifact@v3
                name: Upload generated repo regexes
                with:
                    name: Repo Regexes
                    path: build/regexes/constants.json
    publish-regexes:
        runs-on: ubuntu-latest
        needs: regexes
        name: "Publish regexes"
        if: ${{ 'push' == github.event_name && 'beta' == github.ref_name }}
        steps:
            -   uses: actions/checkout@v3
                with:
                    repository: ${{ env.data_repo }}
                    branch: main
            -   uses: actions/download-artifact@v3
                name: Upload generated repo regexes
                with:
                    name: Repo Regexes
            -   name: Commit generated regex
                run: |
                    mkdir -p constants/
                    mv constants.json constants/regexes.json
                    git config user.name 'github-actions[bot]'
                    git config user.email 'github-action@users.noreply.github.com'
                    git add constants/regexes.json
                    git commit -m "Update regexes based on https://github.com/hannibal002/Skyhanni/commit/$GITHUB_SHA"
            -   name: Publish new repository
                run: |
                    git config --unset-all http.https://github.com/.extraheader
                    git remote add restream https://user:${{secrets.REPO_PAT}}@github.com/${{env.data_repo}}
                    git push restream HEAD:main