-
Notifications
You must be signed in to change notification settings - Fork 546
56 lines (53 loc) · 2.12 KB
/
deps_trigger_gen.yml
File metadata and controls
56 lines (53 loc) · 2.12 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
name: Auto trigger gen code
on:
pull_request:
types: [opened, reopened]
paths:
- '**.mod'
permissions:
contents: read
jobs:
changed-files:
# We auto gen code for service SDK updates (e.g. AWS SDK), but not for our own SDK, as those changes should be handled manually
if: github.event.pull_request.user.login == 'cloudquery-ci[bot]' && startsWith(github.event.pull_request.title, 'fix(deps)') && startsWith(github.head_ref, 'renovate/') && !contains(github.head_ref, 'cloudquery-plugin-sdk')
uses: ./.github/workflows/changed_files.yml
with:
files: |
plugins/source/*/go.mod
plugins/destination/*/go.mod
cli/go.mod
gen-code-deps:
timeout-minutes: 5
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.any_changed == 'true'
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-pull-requests: write
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
env:
SHA: ${{ github.event.pull_request.head.sha }}
GO_MOD_FILES: ${{ needs.changed-files.outputs.changed_files }}
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const path = require('path');
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
const { SHA: sha, GO_MOD_FILES: goModFiles } = process.env;
const goModFilesArray = goModFiles.split(' ');
for (const goModFile of goModFilesArray) {
// e.g. plugins/source/aws/go.mod
const dir = path.dirname(goModFile);
console.log({ issue_number, owner, repo, sha, dir });
await github.rest.issues.createComment({
issue_number,
owner,
repo,
body: `/gen sha=${sha} dir=${dir}`
})
}