File: generated.yml

package info (click to toggle)
nextcloud-spreed-signaling 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,620 kB
  • sloc: sh: 447; makefile: 187; python: 78
file content (117 lines) | stat: -rw-r--r-- 3,225 bytes parent folder | download
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
name: generated

on:
  push:
    branches: [ master ]
    paths:
      - '.github/workflows/generated.yml'
      - 'api*.go'
      - '*_easyjson.go'
      - '*.pb.go'
      - '*.proto'
      - 'go.*'
  pull_request:
    branches: [ master ]
    paths:
      - '.github/workflows/generated.yml'
      - 'api*.go'
      - '*_easyjson.go'
      - '*.pb.go'
      - '*.proto'
      - 'go.*'

env:
  CODE_GENERATOR_NAME: struktur AG service user
  CODE_GENERATOR_EMAIL: opensource@struktur.de

permissions:
  contents: read

jobs:
  check-token:
    runs-on: ubuntu-latest
    outputs:
      token-exists: ${{ steps.token-check.outputs.defined }}
    steps:
      - name: Check for Token availability
        id: token-check
        # perform secret check & put boolean result as an output
        shell: bash
        run: |
          if [ "${{ secrets.CODE_GENERATOR_PAT }}" != '' ]; then
            echo "defined=true" >> $GITHUB_OUTPUT;
          else
            echo "defined=false" >> $GITHUB_OUTPUT;
          fi

  build:
    name: build
    runs-on: ubuntu-latest
    needs: [check-token]
    if: ${{ github.event_name == 'pull_request' && needs.check-token.outputs.token-exists == 'true' }}
    permissions:
      contents: write
    continue-on-error: true
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.CODE_GENERATOR_PAT }}
          ref: ${{ github.event.pull_request.head.ref }}

      - uses: actions/setup-go@v5
        with:
          go-version: "stable"

      - name: Install dependencies
        run: |
          sudo apt -y update && sudo apt -y install protobuf-compiler

      - name: Generate files
        run: |
          make clean-generated
          make common

      - name: Commit changes
        run: |
          CHECKOUT_SHA=$(git rev-parse HEAD)
          echo "Checked out $CHECKOUT_SHA"
          if [ "$CHECKOUT_SHA" != "${{github.event.pull_request.head.sha}}" ]; then
            echo "More changes since this commit ${{github.event.pull_request.head.sha}}, skipping"
          else
            git add *_easyjson.go *.pb.go
            CHANGES=$(git status --porcelain)
            if [ -z "$CHANGES" ]; then
              echo "No files have changed, no need to commit / push."
            else
              go mod tidy
              git add go.*
              git config user.name "$CODE_GENERATOR_NAME"
              git config user.email "$CODE_GENERATOR_EMAIL"
              git commit --author="$(git log -n 1 --pretty=format:%an) <$(git log -n 1 --pretty=format:%ae)>" -m "Update generated files from ${{github.event.pull_request.head.sha}}"
              git push
            fi
          fi

  check:
    name: check
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "stable"

      - name: Install dependencies
        run: |
          sudo apt -y update && sudo apt -y install protobuf-compiler

      - name: Generate files
        run: |
          make clean-generated
          make common

      - name: Check generated files
        run: |
          git add *.go
          git diff --cached --exit-code *.go