99 - master
1010 workflow_dispatch :
1111
12+ # Only allow one such workflow to run at a time
13+ # (since the supplied VirES tokens will only allow 2 max async jobs)
14+ concurrency :
15+ group : ${{ github.workflow }}
16+
1217env :
1318 DOCKER_IMAGE : ' registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook'
1419 PRODUCTION_TAG : ' 1.0.1'
@@ -19,28 +24,34 @@ jobs:
1924 name : Build Jupyter Book
2025 runs-on : ubuntu-latest
2126 steps :
22- - name : Set run reference (branch name or PR number), branch name , and target docker image
27+ - name : Set run references (to switch master/staging/pr behaviour) , and target docker image
2328 run : |
29+
30+ BRANCH_NAME=$(echo "${{ github.ref }}" | sed 's|.*/||')
31+ GH_DEPLOY_ENV="${BRANCH_NAME}"
32+ ENABLE_GH_DEPLOY=$(if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "staging" ]]; then echo "true"; else echo "false"; fi)
33+
2434 if [ "${{ github.event_name }}" == "pull_request" ]; then
2535 RUN_REF="pr${{ github.event.number }}"
26- BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
27- NETLIFY_ALIAS="${{ github.sha }}"
28- GH_DEPLOY_ENV="pull request"
36+ TARGET_BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
2937 elif [ "${{ github.event_name }}" == "push" ]; then
30- RUN_REF=$(echo "${{ github.ref }}" | sed 's|.*/||')
31- BRANCH_NAME=${RUN_REF}
32- NETLIFY_ALIAS="preview-${BRANCH_NAME}"
33- GH_DEPLOY_ENV="${BRANCH_NAME}"
38+ RUN_REF="${BRANCH_NAME}"
39+ TARGET_BRANCH_NAME=${BRANCH_NAME}
40+ elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
41+ RUN_REF="${BRANCH_NAME}"
42+ TARGET_BRANCH_NAME="master"
3443 fi
3544
36- if [ "$BRANCH_NAME " == "staging" ]; then
45+ if [ "$TARGET_BRANCH_NAME " == "staging" ]; then
3746 RESOLVED_DOCKER_IMAGE="${{ env.DOCKER_IMAGE }}:${{ env.STAGING_TAG }}"
38- elif [ "$BRANCH_NAME" == "master" ]; then
47+ else
3948 RESOLVED_DOCKER_IMAGE="${{ env.DOCKER_IMAGE }}:${{ env.PRODUCTION_TAG }}"
4049 fi
4150
4251 echo "RUN_REF=${RUN_REF}" >> $GITHUB_ENV
43- echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
52+ echo "TARGET_BRANCH_NAME=${TARGET_BRANCH_NAME}" >> $GITHUB_ENV
53+ echo "GH_DEPLOY_ENV=${GH_DEPLOY_ENV}" >> $GITHUB_ENV
54+ echo "ENABLE_GH_DEPLOY=${ENABLE_GH_DEPLOY}" >> $GITHUB_ENV
4455 echo "RESOLVED_DOCKER_IMAGE=${RESOLVED_DOCKER_IMAGE}" >> $GITHUB_ENV
4556 - name : Pull the relevant docker image
4657 run : |
5667 mamba create --name bookbuilder --file .bookbuilder/conda-linux-64.lock
5768 '
5869 docker commit temp-container ${{ env.DOCKER_IMAGE }}:customized
59- - name : Execute notebooks using nbmake (staging)
60- if : ${{ env.BRANCH_NAME == " staging" }}
70+ - name : Execute notebooks using nbmake (staging / other )
71+ if : env.TARGET_BRANCH_NAME == ' staging'
6172 run : |
6273 docker run -v $GITHUB_WORKSPACE:/home/jovyan -u root \
6374 -e VIRES_TOKEN=${{ secrets.VIRES_TOKEN }} \
7788 --deselect=notebooks/04c1_Geomag-Ground-Data-FTP.ipynb
7889 '
7990 - name : Execute notebooks using nbmake (production)
80- if : ${{ env.BRANCH_NAME == " master" }}
91+ if : env.TARGET_BRANCH_NAME == ' master'
8192 run : |
8293 docker run -v $GITHUB_WORKSPACE:/home/jovyan -u root \
8394 -e VIRES_TOKEN=${{ secrets.VIRES_TOKEN }} \
@@ -97,24 +108,22 @@ jobs:
97108 docker run -v $GITHUB_WORKSPACE:/home/jovyan -u root ${{ env.DOCKER_IMAGE }}:customized \
98109 bash -c \
99110 '
100- mamba run -n bookbuilder jupyter-book build --config _config-ci-${{ env.BRANCH_NAME }}.yml .
111+ mamba run -n bookbuilder jupyter-book build --config _config-ci-${{ env.TARGET_BRANCH_NAME }}.yml .
101112 '
102113 - name : Deploy preview to Netlify
103114 if : always()
104- uses : nwtgck/actions-netlify@v1.2
115+ uses : nwtgck/actions-netlify@v3.0
105116 with :
106117 publish-dir : ' ./_build/html'
107118 production-deploy : false
108119 github-token : ${{ secrets.GITHUB_TOKEN }}
109120 # RUN_REF is set to one of "master", "staging", "pr#"
110121 deploy-message : " Deploy from GitHub Actions (${{ env.RUN_REF }})"
111- # Alias is used in netlify URL
112- # This is set to one of: "preview-master", "preview-staging", git sha
113- alias : ${{ env.NETLIFY_ALIAS }}
114- # Github deployment environment is one of "master", "staging", "pull request"
122+ # Github deployment environment is one of "master", "staging"
123+ enable-github-deployment : ${{ env.ENABLE_GH_DEPLOY }}
115124 github-deployment-environment : ${{ env.GH_DEPLOY_ENV }}
116125 enable-pull-request-comment : true
117- enable-commit-comment : true
126+ enable-commit-comment : false
118127 overwrites-pull-request-comment : true
119128 env :
120129 NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
0 commit comments