Update fix/clean up #2005
Workflow file for this run
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
name: remove-deploy-previews | |
on: | |
pull_request: | |
branches: | |
- staging | |
types: | |
- closed | |
jobs: | |
branch-name: | |
name: Format branch name string | |
runs-on: ubuntu-latest | |
outputs: | |
lowercase: ${{ steps.string.outputs.lowercase }} # lowercase version | |
steps: | |
- id: string | |
uses: ASzc/change-string-case-action@v5 | |
with: | |
string: ${{ github.head_ref || github.ref_name }} | |
check: | |
name: check changed microservice(s) | |
outputs: | |
remove_preview__auth_service: ${{ steps.check_files.outputs.remove_preview__auth_service }} # auth service | |
remove_preview__device_registry: ${{ steps.check_files.outputs.remove_preview__device_registry }} # device registry | |
remove_preview__device_monitoring: ${{ steps.check_files.outputs.remove_preview__device_monitoring }} # device monitoring | |
remove_preview__data_mgt: ${{ steps.check_files.outputs.remove_preview__data_mgt }} # data mgt | |
remove_preview__data_proxy: ${{ steps.check_files.outputs.remove_preview__data_proxy }} # data proxy | |
remove_preview__analytics: ${{ steps.check_files.outputs.remove_preview__analytics }} # analytics | |
remove_preview__locate: ${{ steps.check_files.outputs.remove_preview__locate }} # locate | |
remove_preview__predict: ${{ steps.check_files.outputs.remove_preview__predict }} # predict | |
remove_preview__meta_data: ${{ steps.check_files.outputs.remove_preview__meta_data }} # meta-data | |
remove_preview__view: ${{ steps.check_files.outputs.remove_preview__view }} # view | |
remove_preview__calibrate: ${{ steps.check_files.outputs.remove_preview__calibrate }} # calibrate | |
remove_preview__incentives: ${{ steps.check_files.outputs.remove_preview__incentives }} #incentives | |
remove_preview__spatial: ${{ steps.check_files.outputs.remove_preview__spatial }} #spatial | |
remove_preview__website: ${{ steps.check_files.outputs.remove_preview__website }} #website | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 2 | |
#### all microservices ###### | |
- name: check modified microserivce | |
id: check_files | |
run: | | |
echo "=============== list modified files ===============" | |
git diff --name-only HEAD^ HEAD | |
echo "========== check paths of modified files ==========" | |
git diff --name-only HEAD^ HEAD > files.txt | |
echo "remove_preview__auth_service=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__device_registry=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__device_monitoring=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__data_mgt=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__data_proxy=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__analytics=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__locate=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__predict=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__meta_data=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__view=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__calibrate=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__incentives=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__spatial=false" >>$GITHUB_OUTPUT | |
echo "remove_preview__website=false" >>$GITHUB_OUTPUT | |
while IFS= read -r file | |
do | |
echo $file | |
if [[ $file == src/auth-service/* ]]; then | |
echo "remove_preview__auth_service=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/device-registry/* ]]; then | |
echo "remove_preview__device_registry=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/device-monitoring/* ]]; then | |
echo "remove_preview__device_monitoring=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/data-mgt/* ]]; then | |
echo "remove_preview__data_mgt=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/data-proxy/* ]]; then | |
echo "remove_preview__data_proxy=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/analytics/* ]]; then | |
echo "remove_preview__analytics=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/locate/* ]]; then | |
echo "remove_preview__locate=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/predict/* ]]; then | |
echo "remove_preview__predict=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/meta-data/* ]]; then | |
echo "remove_preview__meta_data=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/view/* ]]; then | |
echo "remove_preview__view=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/calibrate/* ]]; then | |
echo "remove_preview__calibrate=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/incentives/* ]]; then | |
echo "remove_preview__incentives=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/spatial/* ]]; then | |
echo "remove_preview__spatial=true" >>$GITHUB_OUTPUT | |
fi | |
if [[ $file == src/website/* ]]; then | |
echo "remove_preview__website=true" >>$GITHUB_OUTPUT | |
fi | |
done < files.txt | |
### auth service ### | |
auth-service: | |
name: remove-preview--auth-service | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__auth_service == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-auth-service-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
#### Device Registry ###### | |
device-registry: | |
name: remove-preview--device-registry | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__device_registry == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-device-registry-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### device monitoring ### | |
device-monitoring: | |
name: remove-preview--device-monitoring | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__device_monitoring == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-device-monitoring-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### data-mgt ### | |
data-mgt: | |
name: remove-preview--data-mgt | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__data_mgt == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-data-mgt-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### data-proxy ### | |
data-proxy: | |
name: remove-preview--data-proxy | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__data_proxy == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-data-proxy-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### analytics ### | |
analytics: | |
name: remove-preview--analytics | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__analytics == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-analytics-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### locate ### | |
locate: | |
name: remove-preview--locate | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__locate == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-locate-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### predict api and jobs ### | |
predict-service: | |
name: remove-preview--predict-service | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__predict == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-predict-service-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### meta-data ### | |
meta-data: | |
name: remove-preview-meta-data | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__meta_data == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-meta-data-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### view ### | |
view: | |
name: remove-preview--view | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__view == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-view-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
#### Calibrate ###### | |
calibrate: | |
name: remove-preview--calibrate | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__calibrate == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-calibrate-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### incentives ### | |
incentives: | |
name: build-push-incentives | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__incentives == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-incentives-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### spatial ### | |
spatial: | |
name: build-push-spatial | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__spatial == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-spatial-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet | |
### website ### | |
website: | |
name: build-push-website | |
needs: [check, branch-name] | |
if: needs.check.outputs.remove_preview__website == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: "${{ secrets.GCP_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK | |
uses: "google-github-actions/[email protected]" | |
- name: Delete PR deploy preview | |
run: |- | |
gcloud run services delete ${{ needs.branch-name.outputs.lowercase }}-website-preview \ | |
--region=${{ secrets.REGION }} \ | |
--quiet |