-
Notifications
You must be signed in to change notification settings - Fork 545
69 lines (62 loc) · 2.87 KB
/
manual_commands_triggers.yml
File metadata and controls
69 lines (62 loc) · 2.87 KB
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
name: Manual Commands Triggers
on:
repository_dispatch:
types: [gen-command]
permissions:
contents: read
jobs:
ok-to-run:
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
status: ${{ steps.manually_approved.outputs.result }}
steps:
- name: Check if was manually approved
id: manually_approved
run: |
manually_approved=${{ github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.sha != '' && contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha) }}
echo "result=${manually_approved}" >> $GITHUB_OUTPUT
gen:
timeout-minutes: 30
needs: [ok-to-run]
if: github.event_name == 'repository_dispatch' && github.event.action == 'gen-command' && needs.ok-to-run.outputs.status == 'true'
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
with:
app-id: ${{ secrets.CQ_APP_ID }}
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
permission-contents: write
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.client_payload.slash_command.args.named.sha }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
token: ${{ steps.app-token.outputs.token }}
- name: Setup CloudQuery
uses: cloudquery/setup-cloudquery@4a3af61f7d8c362d8d152a4a17053ed2aaa7180d # v4
with:
version: v6.35.7
- name: Set up Go 1.x
id: setup-go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: ${{ github.event.client_payload.slash_command.args.named.dir }}/go.mod
cache: false
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ steps.setup-go.outputs.go-version }}-gen-${{ github.event.client_payload.slash_command.args.named.dir }}-${{ hashFiles(format('{0}/go.sum', github.event.client_payload.slash_command.args.named.dir)) }}
restore-keys: |
${{ runner.os }}-go-${{ steps.setup-go.outputs.go-version }}-gen-${{ github.event.client_payload.slash_command.args.named.dir }}-
- name: Generate code
run: make gen
working-directory: ${{ github.event.client_payload.slash_command.args.named.dir }}
- uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
with:
commit_message: "chore: Update code and docs"
branch: ${{ github.event.client_payload.pull_request.head.ref }}