yml: git add specific file #53
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 | |
# THIS METHOD OF DOWNLOADING EXPERIENCE BUILDER MAY BREAK IF ESRI CHANGES HOW DOWNLOADS WORK IN THE FUTURE. | |
- 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 | |
# START Download-times | |
- 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. Using the ubuntu text editor 'sed' to swap out the old value for the new one | |
id: modify-file-content | |
run: sed -i "s/${{ steps.download-times-app-exb_demo.outputs.content }}/$INCREMENTED_DT/g" apps/exb_demo/download-times.json | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "Pipeline" | |
git config --global user.email "n.koehn@esri" | |
git add apps/exb_demo/download-times.json | |
git commit -m "download-times modified to $INCREMENTED_DT" | |
git push | |
- name: Echo modified apps/exb_demo/download-times.json | |
run: echo "${{steps.modify-file-content.outputs.content}}" | |
# END Download-times | |
- 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('exb_demo', '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: Deploy app zip to GH Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: exb/ArcGISExperienceBuilder/app |