Skip to content

Commit 2037775

Browse files
authored
Upload zip artifact to gcs after build. (#5736)
* Upload zip artifact to gcs after build.
1 parent 7477e80 commit 2037775

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

.github/workflows/zip.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,22 @@ jobs:
3434
run: |
3535
mkdir -p zip_output_dir
3636
sh -x scripts/build_zip.sh zip_output_dir
37-
3837
- uses: actions/upload-artifact@v1
3938
with:
4039
name: Firebase-actions-dir
4140
# Zip the entire output directory since the builder adds subdirectories we don't know the
4241
# name of.
4342
path: zip_output_dir
43+
- name: Install gcloud tool
44+
if: ${{ always() }}
45+
run: scripts/install_gcloud.sh
46+
- name: Access gcloud account
47+
if: ${{ always() }}
48+
run: |
49+
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firebase-ios-testing.json.gpg firebase-ios-testing.json "$gcs_key"
50+
gcloud auth activate-service-account --key-file firebase-ios-testing.json
51+
- name: Update commit hash on GCS if any previous steps failed
52+
if: ${{ failure() }}
53+
run: scripts/upload_to_gcs.sh "${GITHUB_SHA}" "Fail"
54+
- name: Upload zip file to GCS
55+
run: scripts/upload_to_gcs.sh "${GITHUB_SHA}" "zip_output_dir"
Binary file not shown.

scripts/install_gcloud.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
curl https://sdk.cloud.google.com > install.sh
18+
bash install.sh --disable-prompts
19+
echo "::add-path::${HOME}/google-cloud-sdk/bin/"

scripts/upload_to_gcs.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google LLC
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
set -x
15+
GITHUB_HASH="$1"
16+
FRAMEWORK_DIR="$2"
17+
if [[ "${FRAMEWORK_DIR}" == "Fail" ]]
18+
then
19+
echo "Zip build or gcloud setup might be failed."
20+
echo "The last zip workflow failed. Commit hash: ${GITHUB_HASH}" > latest_commit_hash.txt
21+
gsutil cp latest_commit_hash.txt "gs://ios-framework-zip/latest_commit_hash.txt"
22+
else
23+
echo "Commit Hash: ${GITHUB_HASH}"
24+
zip -r Firebase-actions-dir.zip "${FRAMEWORK_DIR}"
25+
gsutil cp Firebase-actions-dir.zip "gs://ios-framework-zip/Firebase-actions-dir-${GITHUB_HASH}.zip"
26+
# Keep the commit hash, and so SDK testing can load latest zip based on the commit hash.
27+
touch latest_commit_hash.txt
28+
echo "${GITHUB_HASH}" > latest_commit_hash.txt
29+
gsutil cp latest_commit_hash.txt "gs://ios-framework-zip/latest_commit_hash.txt"
30+
fi

0 commit comments

Comments
 (0)