Skip to content

Commit 8e11961

Browse files
authored
Only enable bazel caching writes for tensorflow/io github actions (#1293)
This PR updates so that only GitHub actions run on tensorflow/io repo will be enabled with bazel cache writes. Without the updates, a focked repo actions will cause error. Note once bazel cache read-permissions are enabled from gcs forked repo will be able to access bazel cache (read-only). Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
1 parent 9c9ac76 commit 8e11961

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
env:
1212
GCP_CREDS: ${{ secrets.GCP_CREDS }}
13+
REPO_NAME: ${{ github.repository }}
1314
EVENT_NAME: ${{ github.event_name }}
1415
BAZEL_OPTIMIZATION: --copt=-msse4.2 --copt=-mavx --compilation_mode=opt
1516

@@ -51,7 +52,7 @@ jobs:
5152
steps:
5253
- uses: actions/checkout@v2
5354
- run: |
54-
if [[ "${EVENT_NAME}" == "push" ]]; then
55+
if [[ "${EVENT_NAME}" == "push" && "${REPO_NAME}" == "tensorflow/io" ]]; then
5556
printf '%s\n' "${GCP_CREDS}" >service_account_creds.json
5657
export BAZEL_OPTIMIZATION="--remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
5758
fi
@@ -71,7 +72,7 @@ jobs:
7172
steps:
7273
- uses: actions/checkout@v2
7374
- run: |
74-
if [[ "${EVENT_NAME}" == "push" ]]; then
75+
if [[ "${EVENT_NAME}" == "push" && "${REPO_NAME}" == "tensorflow/io" ]]; then
7576
printf '%s\n' "${GCP_CREDS}" >service_account_creds.json
7677
export BAZEL_OPTIMIZATION="--remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
7778
fi
@@ -89,7 +90,7 @@ jobs:
8990
steps:
9091
- uses: actions/checkout@v2
9192
- run: |
92-
if [[ "${EVENT_NAME}" == "push" ]]; then
93+
if [[ "${EVENT_NAME}" == "push" && "${REPO_NAME}" == "tensorflow/io" ]]; then
9394
printf '%s\n' "${GCP_CREDS}" >service_account_creds.json
9495
export BAZEL_OPTIMIZATION="--remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
9596
fi
@@ -108,7 +109,7 @@ jobs:
108109
- uses: actions/checkout@v2
109110
- name: Bazel on macOS
110111
run: |
111-
if [[ "${EVENT_NAME}" == "push" ]]; then
112+
if [[ "${EVENT_NAME}" == "push" && "${REPO_NAME}" == "tensorflow/io" ]]; then
112113
printf '%s\n' "${GCP_CREDS}" >service_account_creds.json
113114
export BAZEL_OPTIMIZATION="${BAZEL_OPTIMIZATION} --remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
114115
fi
@@ -219,7 +220,7 @@ jobs:
219220
- uses: actions/checkout@v2
220221
- name: Bazel on Linux
221222
run: |
222-
if [[ "${EVENT_NAME}" == "push" ]]; then
223+
if [[ "${EVENT_NAME}" == "push" && "${REPO_NAME}" == "tensorflow/io" ]]; then
223224
printf '%s\n' "${GCP_CREDS}" >service_account_creds.json
224225
export BAZEL_OPTIMIZATION="${BAZEL_OPTIMIZATION} --remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
225226
fi
@@ -327,8 +328,12 @@ jobs:
327328
shell: cmd
328329
run: |
329330
if "%EVENT_NAME%" == "push" (
330-
printenv GCP_CREDS > service_account_creds.json
331-
set "BAZEL_OPTIMIZATION=--remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
331+
if "%REPO_NAME%" == "tensorflow/io" (
332+
printenv GCP_CREDS > service_account_creds.json
333+
set "BAZEL_OPTIMIZATION=--remote_cache=https://storage.googleapis.com/tensorflow-sigs-io --remote_upload_local_results=true --google_credentials=service_account_creds.json"
334+
) else (
335+
echo %REPO_NAME%
336+
)
332337
) else (
333338
echo %EVENT_NAME%
334339
)

0 commit comments

Comments
 (0)