-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into update-fix/Analytics-data-export-cleanup
Updates from airqo staging
- Loading branch information
Showing
41 changed files
with
3,287 additions
and
1,083 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 |
---|---|---|
|
@@ -56,6 +56,7 @@ jobs: | |
run_incentives: ${{ steps.check_files.outputs.run_incentives }} # incentives | ||
run_insights: ${{ steps.check_files.outputs.run_insights }} # incentives | ||
run_spatial: ${{ steps.check_files.outputs.run_spatial }} # spatial | ||
run_website: ${{ steps.check_files.outputs.run_website }} # website | ||
run_kafka_connectors: ${{ steps.check_files.outputs.run_kafka_connectors }} # kafka connectors | ||
run_nginx: ${{ steps.check_files.outputs.run_nginx }} # nginx ingress | ||
|
||
|
@@ -98,6 +99,7 @@ jobs: | |
echo "run_incentives=false" >>$GITHUB_OUTPUT | ||
echo "run_insights=false" >>$GITHUB_OUTPUT | ||
echo "run_spatial=false" >>$GITHUB_OUTPUT | ||
echo "run_website=false" >>$GITHUB_OUTPUT | ||
echo "run_kafka_connectors=false" >>$GITHUB_OUTPUT | ||
echo "run_nginx=false" >>$GITHUB_OUTPUT | ||
|
@@ -271,6 +273,14 @@ jobs: | |
if [[ $file == k8s/spatial/* ]]; then | ||
echo "run_spatial=true" >>$GITHUB_OUTPUT | ||
fi | ||
if [[ $file == src/website/* ]]; then | ||
echo "run_website=true" >>$GITHUB_OUTPUT | ||
fi | ||
if [[ $file == k8s/website/* ]]; then | ||
echo "run_website=true" >>$GITHUB_OUTPUT | ||
fi | ||
if [[ $file == k8s/nginx/staging/* ]]; then | ||
|
@@ -296,6 +306,7 @@ jobs: | |
echo "run_incentives=true" >>$GITHUB_OUTPUT | ||
echo "run_insights=true" >>$GITHUB_OUTPUT | ||
echo "run_spatial=true" >>$GITHUB_OUTPUT | ||
echo "run_website=true" >>$GITHUB_OUTPUT | ||
echo "run_view=true" >>$GITHUB_OUTPUT | ||
echo "run_kafka_connectors=true" >>$GITHUB_OUTPUT | ||
echo "run_nginx=true" >>$GITHUB_OUTPUT | ||
|
@@ -1723,6 +1734,66 @@ jobs: | |
gcloud secrets versions access latest --secret="sta-key-analytics-service-account" > google_application_credentials.json | ||
kubectl create configmap --dry-run=client -o yaml --from-file=google_application_credentials.json stage-spatial-api-config-files | kubectl replace -f - -n staging | ||
### website ### | ||
website: | ||
name: build-push-deploy-website | ||
needs: [check, image-tag] | ||
if: needs.check.outputs.run_website == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Login to GCR | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY_URL }} | ||
username: _json_key | ||
password: ${{ secrets.GCR_CONFIG }} | ||
|
||
- name: Login to K8S | ||
uses: azure/[email protected] | ||
with: | ||
method: kubeconfig | ||
kubeconfig: ${{ secrets.K8S_CONFIG_STAGE }} | ||
|
||
- name: Build and Push Docker Image | ||
run: | | ||
cd src/website/ | ||
docker build --tag ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/airqo-stage-website-api:${{ needs.image-tag.outputs.build_id }} . | ||
docker tag ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/airqo-stage-website-api:${{ needs.image-tag.outputs.build_id }} ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/airqo-stage-website-api:latest | ||
docker push ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/airqo-stage-website-api:${{ needs.image-tag.outputs.build_id }} | ||
docker push ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/airqo-stage-website-api:latest | ||
- name: Update corresponding helm values file(with retry) | ||
uses: Wandalen/[email protected] # Retries action on fail | ||
with: | ||
action: fjogeleit/yaml-update-action@main # Action to retry | ||
with: | | ||
valueFile: "k8s/website/values-stage.yaml" | ||
propertyPath: "image.tag" | ||
value: ${{ needs.image-tag.outputs.build_id }} | ||
branch: ${{ env.DEPLOY_BRANCH }} | ||
token: ${{ secrets.YAML_UPDATER_TOKEN }} | ||
message: "Update website staging image tag to ${{ needs.image-tag.outputs.build_id }}" | ||
- name: Login to GCP | ||
uses: google-github-actions/[email protected] | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_CREDENTIALS }} | ||
|
||
- name: Setup Cloud SDK | ||
uses: google-github-actions/[email protected] | ||
|
||
- name: Update the corresponding k8s configmap(s) | ||
run: | | ||
cd src/website/ | ||
gcloud secrets versions access latest --secret="sta-env-website-backend" > .env | ||
kubectl create configmap --dry-run=client -o yaml --from-env-file=.env stage-website-api-config | kubectl replace -f - -n staging | ||
gcloud secrets versions access latest --secret="sta-key-analytics-service-account" > google_application_credentials.json | ||
kubectl create configmap --dry-run=client -o yaml --from-file=google_application_credentials.json stage-website-api-config-files | kubectl replace -f - -n staging | ||
### apply nginx ### | ||
nginx: | ||
name: apply-nginx | ||
|
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 |
---|---|---|
|
@@ -37,6 +37,7 @@ jobs: | |
run_calibrate: ${{ steps.check_files.outputs.run_calibrate }} # calibrate | ||
run_incentives: ${{ steps.check_files.outputs.run_incentives }} # incentives | ||
run_spatial: ${{ steps.check_files.outputs.run_spatial }} # spatial | ||
run_website: ${{ steps.check_files.outputs.run_website }} # website | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
|
@@ -67,6 +68,7 @@ jobs: | |
echo "run_calibrate=false" >>$GITHUB_OUTPUT | ||
echo "run_incentives=false" >>$GITHUB_OUTPUT | ||
echo "run_spatial=false" >>$GITHUB_OUTPUT | ||
echo "run_website=false" >>$GITHUB_OUTPUT | ||
while IFS= read -r file | ||
do | ||
|
@@ -123,6 +125,10 @@ jobs: | |
echo "run_spatial=true" >>$GITHUB_OUTPUT | ||
fi | ||
if [[ $file == src/website/* ]]; then | ||
echo "run_website=true" >>$GITHUB_OUTPUT | ||
fi | ||
done < files.txt | ||
|
@@ -1139,3 +1145,81 @@ jobs: | |
repo: context.repo.repo, | ||
body: 'Spatial changes in this PR available for preview [here](${{ needs.spatial.outputs.url }})' | ||
}) | ||
### website ### | ||
website: | ||
name: build-push-deploy-website | ||
needs: [check, branch-name] | ||
if: needs.check.outputs.run_website == 'true' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
outputs: | ||
url: ${{ steps.preview-url.outputs.url }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
- 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: Docker Auth | ||
id: docker-auth | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY_URL }} | ||
username: _json_key | ||
password: ${{ secrets.GCP_SA_CREDENTIALS }} | ||
|
||
- name: Build and Push Container | ||
run: | | ||
cd src/website/ | ||
docker build --tag ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/pr-previews/website-pr-previews:${{ github.sha }} ./ | ||
docker push ${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/pr-previews/website-pr-previews:${{ github.sha }} | ||
- name: Deploy to Cloud Run | ||
run: |- | ||
gcloud run deploy ${{ needs.branch-name.outputs.lowercase }}-website-preview \ | ||
--region=${{ secrets.REGION }} \ | ||
--max-instances=10 \ | ||
--timeout=60 \ | ||
--concurrency=10 \ | ||
--image=${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/pr-previews/website-pr-previews:${{ github.sha }} \ | ||
--port=8000 \ | ||
--cpu=1000m \ | ||
--memory=1024Mi \ | ||
--update-secrets=/etc/env/.env=sta-env-website-backend:latest,/etc/config/google_application_credentials.json=sta-key-analytics-service-account:latest \ | ||
--command="/bin/sh","-c","cat /etc/env/.env >> /app/.env; /app/entrypoint.sh" \ | ||
--allow-unauthenticated | ||
- name: Get preview service url | ||
id: preview-url | ||
run: | | ||
read service_url < <(gcloud run services describe ${{ needs.branch-name.outputs.lowercase }}-website-preview \ | ||
--format='value(status.url)' \ | ||
--platform managed \ | ||
--region ${{ secrets.REGION }}) | ||
echo "url=${service_url}" >>$GITHUB_OUTPUT | ||
website-pr-comment: | ||
name: website-preview-link-comment | ||
if: needs.check.outputs.run_website == 'true' | ||
needs: [website] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'website changes in this PR available for preview [here](${{ needs.website.outputs.url }})' | ||
}) |
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ jobs: | |
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: | ||
|
@@ -66,6 +67,7 @@ jobs: | |
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 | ||
|
@@ -120,7 +122,11 @@ jobs: | |
if [[ $file == src/spatial/* ]]; then | ||
echo "remove_preview__spatial=true" >>$GITHUB_OUTPUT | ||
fi | ||
fi | ||
if [[ $file == src/website/* ]]; then | ||
echo "remove_preview__website=true" >>$GITHUB_OUTPUT | ||
fi | ||
done < files.txt | ||
|
@@ -409,3 +415,25 @@ jobs: | |
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 |
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -190,5 +190,6 @@ spec: | |
- name: Content-Type | ||
value: application/json | ||
|
||
|
||
|
||
|
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
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
Oops, something went wrong.