-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (80 loc) · 2.62 KB
/
auto_update.yml
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
name: Auto Update
on:
workflow_dispatch:
schedule:
# Check everyday at 20:00 UTC
- cron: '0 20 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
auto_update_module:
name: "Auto Update Module"
runs-on: ubuntu-22.04
steps:
- name: Set up Go 1.20.x
uses: actions/setup-go@v5
with:
go-version: 1.20.x
cache: false
id: go
- uses: actions/checkout@v4
- name: Install Buildifier
run: |
cd $(mktemp -d)
GO111MODULE=on go install github.com/bazelbuild/buildtools/buildifier@latest
# Checkout repository
- uses: actions/checkout@v4
with:
path: libraries/bzlmodrio-ni
# Checkout gentool
- uses: actions/checkout@v4
with:
repository: 'bzlmodRio/gentool.git'
fetch-depth: 0
path: gentool
ref: refactor_dev
- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/bzlmod_cache/*.sha256
key: ${{ runner.os }}-${{ hashFiles('**/generate/**') }}
restore-keys: |
${{ runner.os }}-
${{ runner.os }}
# Run update
- name: Run update
run: bazel run //:auto_update
working-directory: libraries/bzlmodrio-ni/generate
- name: Generate if changed
run: |
if [[ $(git --no-pager diff --exit-code HEAD) != '' ]]; then
echo "Something changed, need to re-generate"
bazel run //:generate
buildifier -warnings all --lint=fix -r ..
cd ..
bazel build //... --nobuild --enable_bzlmod --lockfile_mode=update -k || true
cd tests
bazel build //... --nobuild --enable_bzlmod --lockfile_mode=update -k || true
# Pull requests won't be created if the github actions change. Since for this
# We mostly care about the actual code changes, we will just revert those files
git checkout ../.github/workflows
else
echo "No changes!"
fi;
working-directory: libraries/bzlmodrio-ni/generate
- name: Store new version
run: echo "NEW_VERSION=$(bazel run //:get_version)" >> $GITHUB_ENV
working-directory: libraries/bzlmodrio-ni/generate
# Create pull requests
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
env:
GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_KEY }}
with:
path: libraries/bzlmodrio-ni
base: main
token: ${{ secrets.AUTO_UPDATE_KEY }}
branch: autoupdate_${{ env.NEW_VERSION }}
title: "Auto Update to '${{ env.NEW_VERSION }}'"