-
Notifications
You must be signed in to change notification settings - Fork 23
66 lines (59 loc) · 2.17 KB
/
update-deps.yaml
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
name: Update cnuery and provider dependencies
on:
schedule:
- cron: "11 8 * * 1" # every monday
workflow_dispatch:
jobs:
update-deps:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.CNQUERY_DEPLOY_KEY_PRIV }}
- name: Import environment variables from file
run: cat ".github/env" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ">=${{ env.golang-version }}"
cache: false
- name: Update deps
id: update-deps
run: |
shopt -s expand_aliases
alias version="go run providers-sdk/v1/util/version/version.go"
version mod-update . --latest
version mod-update providers/*/ --latest
version mod-tidy providers/*/
version mod-tidy .
echo "COUNT_GOMOD=$(git status --short --untracked-files=no | wc -l)" >> $GITHUB_OUTPUT
- name: Commit changes upstream
id: branch
if: ${{ steps.update-deps.outputs.COUNT_GOMOD != '0' }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Mondoo Tools"
BRANCH_NAME="version/deps_update_$(date +%Y%m%d_%H%M)"
git checkout -b ${BRANCH_NAME}
git add go.mod go.sum || true
git add providers/ || true
COMMIT_MSG="🧹 Update deps for cnquery and providers $(date +%Y%m%d)"
echo "COMMIT_TITLE=${COMMIT_MSG}" >> $GITHUB_OUTPUT
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
git commit -m "${COMMIT_MSG}"
git push --set-upstream origin ${BRANCH_NAME}
shell: bash
- name: Create pull request
if: ${{ steps.update-deps.outputs.COUNT_GOMOD != '0' }}
uses: peter-evans/create-pull-request@v5
with:
draft: true
base: main
labels: dependencies,go
title: ${{ steps.branch.outputs.COMMIT_TITLE }}
branch: ${{ steps.branch.outputs.BRANCH_NAME }}
body-path: .github/pr-body.md