-
Notifications
You must be signed in to change notification settings - Fork 1.2k
70 lines (60 loc) · 2.1 KB
/
update-deb-package-snapshots.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
name: update-snapshots
on:
# will send emails to last editor of this cron syntax (distroless-bot)
schedule:
- cron: "35 20 * * *"
# allow this workflow to be manually run
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
- name: Update snapshots
run: ./knife github-update-snapshots
- name: Run update sboms script
if: env.DISTROLESS_DIFF
run: |
for i in $(seq 5); do
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc fetch //private/pkg/test/oci_image:test_sboms && break || sleep 20;
done
bazel run @//private/pkg/test/oci_image:test_sboms
- name: Run update lockfile
if: env.DISTROLESS_DIFF
run: bazel mod deps --lockfile_mode=update
- name: Create commits
if: env.DISTROLESS_DIFF
id: create-commits
run: |
git checkout -b update-snapshots
# Set identity.
git config --global user.email "distroless-bot@google.com"
git config --global user.name "Distroless Bot"
# Commit changes
git add .
git commit -s -m "Bumping packages to latest stable versions"
git push --force origin HEAD
- name: Create Pull Request
if: env.DISTROLESS_DIFF
env:
GH_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
run: |
BODY_FILE=$(mktemp)
printf "Bumping packages to latest stable version\n\`\`\`diff\n$DISTROLESS_DIFF\n\`\`\`\n" >> $BODY_FILE
if ! OUTPUT=$(gh pr create -B main -H update-snapshots -t "Bumping packages to latest stable versions" --body-file "$BODY_FILE" 2>&1) ; then
echo $OUTPUT
if [[ "${OUTPUT}" =~ "already exists" ]]; then
echo "PR already exists and it was updated. Ending successfully";
exit 0;
else
exit 1;
fi
fi