-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(web): add an action to update ion token (#561)
- Loading branch information
Showing
1 changed file
with
38 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,38 @@ | ||
name: Update Cesium Ion access token (test) | ||
on: | ||
schedule: | ||
- cron: "0 0 2 * *" | ||
workflow_dispatch: | ||
env: | ||
GCS_DOMAIN: gs://test.reearth.dev | ||
REEARTH_CONFIG_FILENAME: reearth_config.json | ||
jobs: | ||
update_ion_token: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/auth@v0 | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v0 | ||
- name: Download reearth config | ||
run: gsutil cp "${{ env.GCS_DOMAIN }}/${{ env.REEARTH_CONFIG_FILENAME }}" . | ||
- name: Get Cesium Ion token | ||
id: ion_token | ||
run: | | ||
ION_TOKEN=$(\ | ||
curl https://raw.githubusercontent.com/CesiumGS/cesium/main/packages/engine/Source/Core/Ion.js \ | ||
| node -e "console.log(\ | ||
require('fs')\ | ||
.readFileSync(process.stdin.fd)\ | ||
.toString()\ | ||
.match(/const defaultAccessToken =(\n| ).*\"(.*)\";/)[2]\ | ||
)"\ | ||
) | ||
echo "token=${ION_TOKEN}" >> $GITHUB_OUTPUT | ||
- name: Update Ion token in reearth config | ||
run: | | ||
echo $(cat ${{ env.REEARTH_CONFIG_FILENAME }} | jq -r '.cesiumIonAccessToken |= "${{ steps.ion_token.outputs.token }}"') > ${{ env.REEARTH_CONFIG_FILENAME }} | ||
echo $(cat ${{ env.REEARTH_CONFIG_FILENAME }}) | ||
- name: Upload reearth config | ||
run: gsutil -h "Cache-Control:no-store" cp reearth_config.json "${{ env.GCS_DOMAIN }}/${{ env.REEARTH_CONFIG_FILENAME }}" |