-
Notifications
You must be signed in to change notification settings - Fork 375
115 lines (111 loc) · 4.56 KB
/
update-googleapis-sha.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: "Update the google apis"
on: push
# on:
# # Create the PR once a week at 12:00 on Monday.
# schedule:
# - cron: '0 12 * * MON'
# push:
# branches: [ 'ci-gha-googleapis**' ]
permissions:
contents: write
pull-requests: write
id-token: 'write'
env:
REPO: googleapis/googleapis
BRANCH: master
jobs:
create-update-google-apis-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Store the current date as an environment variable
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: 'Authenticate to GCP'
uses: google-github-actions/auth@v1
# We can't use WIF since one of the steps needs access to create a storage project.
with:
create_credentials_file: true
credentials_json: ${{ secrets.GHA_STORAGE_SERVICE_ACCOUNT_CREDENTIALS_JSON }}
- name: 'Set up Cloud SDK'
uses: google-github-actions/setup-gcloud@v1
with:
version: '>= 390.0.0'
- name: Get latest commit from google apis
run: |
echo "COMMIT=$(curl --retry 5 -fsSL -H 'Accept: application/vnd.github.VERSION.sha' 'https://api.github.com/repos/${{ env.REPO }}/commits/${{ env.BRANCH}}')" >> $GITHUB_ENV
- name: Get the SHA for google apis and store the archieve in our storage bucket
run: |
DOWNLOAD="$(mktemp)"
curl -fsSL "https://github.com/${{ env.REPO }}/archive/${{ env.COMMIT }}.tar.gz" -o "${DOWNLOAD}"
gsutil -q cp "${DOWNLOAD}" "gs://cloud-cpp-community-archive/com_google_googleapis/${{ env.COMMIT }}.tar.gz"
echo 'SHA256=$(sha256sum "${DOWNLOAD}" | sed "s/ .*//")' >> $GITHUB_ENV
rm -rf ${DOWNLOAD}
- name: Updating Bazel dependencies
run: |
sed -i -f - bazel/google_cloud_cpp_deps.bzl <<EOT
/name = "com_google_googleapis",/,/strip_prefix = "/ {
s;/com_google_googleapis/.*.tar.gz",;/com_google_googleapis/${COMMIT}.tar.gz",;
s;/${REPO}/archive/.*.tar.gz",;/${REPO}/archive/${COMMIT}.tar.gz",;
s/sha256 = ".*",/sha256 = "${SHA256}",/
s/strip_prefix = "googleapis-.*",/strip_prefix = "googleapis-${COMMIT}",/
}
EOT
env:
COMMIT: ${{ env.COMMIT }}
REPO: ${{ env.REPO }}
SHA256: ${{ vars.SHA256 }}
- name: Updating CMake dependencies
run: |
sed -i -f - cmake/GoogleapisConfig.cmake <<EOT
/^set(_GOOGLE_CLOUD_CPP_GOOGLEAPIS_COMMIT_SHA$/ {
n
s/".*"/"${COMMIT}"/
}
/^set(_GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256$/ {
n
s/".*"/"${SHA256}"/
}
EOT
env:
COMMIT: ${{ env.COMMIT }}
SHA256: ${{ vars.SHA256 }}
- name: Check if there are any updates
id: diff-deps
run: |
if [[ git diff --quiet bazel/google_cloud_cpp_deps.bzl \
cmake/GoogleapisConfig.cmake ]]; then
echo "No updates"
exit 0
fi
- name: Updating the protodeps/protolists
run: external/googleapis/update_libraries.sh
- name: Regenerating libraries
run: | # generate-libraries fails if it creates a diff, so ignore its status.
ci/cloudbuild/build.sh --docker --trigger=generate-libraries-pr || true
- name: Verify everything compiles with Bazel
run: bazel build //google/cloud/...
- name: Verify everything compiles with CMake
run: ci/cloudbuild/build.sh -t cmake-install-pr
- name: Create commits
run: |
git config user.name 'Anonymous'
git config user.email '<>'
git commit -m"chore: update googleapis SHA circa $(date +%Y-%m-%d)" \
bazel/google_cloud_cpp_deps.bzl cmake/GoogleapisConfig.cmake
if ! git diff --quiet external/googleapis/protodeps \
external/googleapis/protolists; then
git commit -m"Update the protodeps/protolists" \
external/googleapis/protodeps external/googleapis/protolists
fi
if ! git diff --quiet .; then
git commit -m"Regenerate libraries" .
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: 'chore(googleapis-sha): update the sha circa ${{ env.DATE }}'
body: >
This PR is auto-generated by
[updated-googleapis-sha](https://github.com/googleapis/google-cloud-cpp/.github/workflows/update-googleapis-sha).
labels: dependencies