yml: update to checkout@v4 using node 20 #45
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: Deploy Experience Builder Apps | |
on: | |
push: | |
branches: | |
- master | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
Deploy-Experience-Builder-Apps: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Download Experience Builder | |
run: curl -o exb.zip "$(curl -s 'https://downloads.arcgis.com/dms/rest/download/secured/arcgis-experience-builder-1.14.zip?f=json&folder=software%2FExperienceBuilder%2F1.14' | python3 -c "import sys, json; print(json.load(sys.stdin)['url'])")" | |
# the "classic" way of downloading via "npx arcgis-lib-downloader -p arcgis-experience-builder -v 1.14" doesn't work anymore! :/ | |
# see this blog article: https://community.esri.com/t5/arcgis-experience-builder-questions/download-experience-builder-via-cmd/td-p/1391180 | |
# WARNING: | |
# THIS METHOD OF DOWNLOADING EXPERIENCE BUILDER MAY BREAK IF ESRI CHANGES HOW DOWNLOADS WORK IN THE FUTURE. | |
# IN OTHER WORDS, IT COULD BREAK AT ANY TIME. | |
# THERE IS NO WARRANTY OR GUARANTEE THAT THIS COMMAND WILL WORK IN THE FUTURE. | |
# ONLY USE THIS COMMAND IF YOU UNDERSTAND HOW IT IS BEING USED AND ARE COMFORTABLE FIXING IT IF IT BREAKS: | |
- name: Unzip Experience Builder | |
run: unzip -q exb.zip -d exb | |
- name: Copy Custom Widgets | |
run: cp -r widgets/* exb/ArcGISExperienceBuilder/client/your-extensions/widgets | |
- name: Install Custom Widgets dependencies | |
run: node npm-install-subfolders.js ./exb/ArcGISExperienceBuilder/client/your-extensions/widgets | |
- name: Create App directory | |
run: mkdir public && cd public && mkdir apps && cd apps | |
working-directory: exb/ArcGISExperienceBuilder/server | |
- name: Copy apps | |
run: cp -r apps/* exb/ArcGISExperienceBuilder/server/public/apps | |
- name: Read apps/exb_demo/download-times.json | |
id: download-times-app-exb_demo | |
uses: jaywcjlove/github-action-read-file@main | |
with: | |
path: apps/exb_demo/download-times.json | |
- name: Read DT file variable | |
run: echo "${{ steps.download-times-app-exb_demo.outputs.content }}" | |
- name: Set env variable | |
run: echo "INCREMENTED_DT=$((${{ steps.download-times-app-exb_demo.outputs.content }} + 1))" >> $GITHUB_ENV | |
- name: Echo INCREMENTED_DT | |
run: echo "$INCREMENTED_DT" | |
- name: Modify apps/exb_demo/download-times.json | |
id: modify-file-content | |
uses: jaywcjlove/github-action-modify-file-content@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: apps/exb_demo/download-times.json | |
# TODO: this does not work. need alternative. => https://github.com/jaywcjlove/github-action-modify-file-content/issues/8#issuecomment-1413120240 | |
body: "{{$INCREMENTED_DT}}" | |
overwrite: true | |
message: "Increment download times to {{$INCREMENTED_DT}}" | |
branch: master | |
- name: Echo modified apps/app-exb/download-times.json | |
run: echo "${{steps.modify-file-content.outputs.content}}" | |
- name: NPM install client folder | |
run: npm ci | |
working-directory: exb/ArcGISExperienceBuilder/client | |
- name: NPM install in server folder | |
run: npm ci | |
working-directory: exb/ArcGISExperienceBuilder/server | |
- name: Build widgets | |
run: npm run build:prod | |
working-directory: exb/ArcGISExperienceBuilder/client | |
- name: Run download script | |
# include clientId of the app, as explained here: https://community.esri.com/t5/arcgis-experience-builder-blog/experience-builder-devops-generating-the-app/ba-p/1112247 | |
run: node -e "require('./server/src/middlewares/dev/apps/app-download.js').zipApp('2', 'app.zip', 'pSM9aNISD0wgzyXA')" | |
working-directory: exb/ArcGISExperienceBuilder | |
env: | |
NODE_ENV: production | |
- name: Unzip app zip | |
# ExB has non-standard file permissions so use chmod after unzip | |
run: | | |
unzip -q app.zip -d app | |
chmod -R 777 app | |
working-directory: exb/ArcGISExperienceBuilder | |
- name: Generate screenshot (optional) | |
working-directory: exb/ArcGISExperienceBuilder/app | |
continue-on-error: true | |
run: | | |
npm install --global pageres-cli | |
npm install --global serve | |
echo "{\"trailingSlash\":true}" > serve.json | |
serve . -p 5000 & | |
pageres http://localhost:5000/index.html 1024x768 --filename=screenshot --delay=10 | |
- name: Deploy app zip to GH Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: exb/ArcGISExperienceBuilder/app |