-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Watcher - devnet | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
changed_files: | ||
runs-on: ubuntu-latest | ||
name: Get changed files | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: GCP Auth | ||
id: auth | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
credentials_json: ${{ secrets.DEV_GCP_CREDENTIALS }} | ||
|
||
- name: Setup GCP SDK | ||
id: setup-sdk | ||
uses: google-github-actions/setup-gcloud@v1 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: devnets/** | ||
files_ignore: devnets/initia/** | ||
|
||
- name: Get current time | ||
uses: initia-labs/actions/get-current-time@main | ||
id: current-time | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
|
||
- name: Copy changed files to GCS | ||
env: | ||
ALL_ADDED_FILES: ${{ steps.changed-files.outputs.added_files }} | ||
ALL_MODIFIED_FILES: ${{ steps.changed-files.outputs.modified_files }} | ||
ALL_DELETED_FILES: ${{ steps.changed-files.outputs.deleted_files }} | ||
CURRENT_TIME: ${{ steps.current-time.outputs.formattedTime }} | ||
|
||
run: | | ||
if [ -n "${ALL_ADDED_FILES}" ]; then | ||
for add in ${ALL_ADDED_FILES}; do | ||
echo "Copying $add to GCS..." | ||
path=$(dirname "$add") | ||
gsutil -m cp "$add" gs://dev-initia-registry/v1/"$CURRENT_TIME"/added/"$path"/ | ||
done | ||
fi | ||
if [ -n "${ALL_MODIFIED_FILES}" ]; then | ||
for mod in ${ALL_MODIFIED_FILES}; do | ||
echo "Copying $mod to GCS..." | ||
path=$(dirname "$mod") | ||
gsutil -m cp "$mod" gs://dev-initia-registry/v1/"$CURRENT_TIME"/modified/"$path"/ | ||
done | ||
fi | ||
if [ -n "${ALL_DELETED_FILES}" ]; then | ||
touch deleted_files | ||
for del in ${ALL_DELETED_FILES}; do | ||
echo "Writing $del to file..." | ||
echo "$del" >> deleted_files | ||
done | ||
gsutil -m cp deleted_files gs://dev-initia-registry/v1/"$CURRENT_TIME"/deleted/ | ||
fi |