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@v3 | |
- name: Download Experience Builder | |
run: npx arcgis-lib-downloader -p arcgis-experience-builder -v 1.13 -t Download | |
env: | |
ARCGIS_LIB_DOWNLOADER_USERNAME: ${{ secrets.ARCGIS_LIB_DOWNLOADER_USERNAME }} | |
ARCGIS_LIB_DOWNLOADER_PASSWORD: ${{ secrets.ARCGIS_LIB_DOWNLOADER_PASSWORD }} | |
- name: Unzip Experience Builder | |
run: unzip -q arcgis-experience-builder-1.13.zip -d arcgis-experience-builder-1.13 | |
- name: Copy Custom Widgets | |
run: cp -r widgets/* arcgis-experience-builder-1.13/ArcGISExperienceBuilder/client/your-extensions/widgets | |
- name: Install Custom Widgets dependencies | |
run: node npm-install-subfolders.js ./arcgis-experience-builder-1.13/ArcGISExperienceBuilder/client/your-extensions/widgets | |
- name: Create App directory | |
run: mkdir public && cd public && mkdir apps && cd apps | |
working-directory: arcgis-experience-builder-1.13/ArcGISExperienceBuilder/server | |
- name: Copy apps | |
run: cp -r apps/* arcgis-experience-builder-1.13/ArcGISExperienceBuilder/server/public/apps | |
- name: Read apps/2/download-times.json | |
id: download-times-app-2 | |
uses: jaywcjlove/github-action-read-file@main | |
with: | |
path: apps/2/download-times.json | |
- name: Set env variable | |
run: echo "INCREMENTED_DT=$((${{ steps.download-times-app-2.outputs.content }} + 1))" >> $GITHUB_ENV | |
- name: Increment and echo | |
run: | | |
content=$(echo "${{ steps.download-times-app-2.outputs.content }}" | tr -d '\n') | |
echo $((content + 1)) | |
shell: bash | |
- name: Echo INCREMENTED_DT | |
run: echo "$INCREMENTED_DT" | |
- name: Modify apps/2/download-times.json | |
uses: jaywcjlove/github-action-modify-file-content@main | |
with: | |
path: apps/2/download-times.json | |
body: "$INCREMENTED_DT" | |
- name: Commit & Push | |
uses: actions-js/push@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
force: true | |
message: 'Overwritten by Github Actions - ${date}' | |
- name: NPM install client folder | |
run: npm ci | |
working-directory: arcgis-experience-builder-1.13/ArcGISExperienceBuilder/client | |
- name: NPM install in server folder | |
run: npm ci | |
working-directory: arcgis-experience-builder-1.13/ArcGISExperienceBuilder/server | |
- name: Build widgets | |
run: npm run build:prod | |
working-directory: arcgis-experience-builder-1.13/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: arcgis-experience-builder-1.13/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: arcgis-experience-builder-1.13/ArcGISExperienceBuilder | |
- name: Generate screenshot (optional) | |
working-directory: arcgis-experience-builder-1.13/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: arcgis-experience-builder-1.13/ArcGISExperienceBuilder/app |