deploy #267
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
# Deploy projects to AE5 | |
# Runs on: | |
# merged PRs: deploy projects that changed compared to the previous commit, | |
# or, remove AE5 projects when the projects were removed from the remo | |
# schedule: deploy the template project | |
# workflow_dispatch: to deploy projects if that didn't worked after merging the PR | |
name: deploy | |
on: | |
pull_request: | |
branches: | |
- "main" | |
types: | |
- closed | |
# Run it from the UI | |
workflow_dispatch: | |
inputs: | |
all: | |
description: all the projects | |
type: boolean | |
default: false | |
required: true | |
projects: | |
description: comma-separated list | |
type: string | |
required: false | |
schedule: | |
- cron: '0 3 * * SUN' | |
env: | |
EXAMPLES_HOLOVIZ_AE5_ADMIN_USERNAME: ${{ secrets.EXAMPLES_HOLOVIZ_AE5_ADMIN_USERNAME }} | |
EXAMPLES_HOLOVIZ_AE5_ADMIN_PASSWORD: ${{ secrets.EXAMPLES_HOLOVIZ_AE5_ADMIN_PASSWORD }} | |
EXAMPLES_HOLOVIZ_AE5_USERNAME: ${{ secrets.EXAMPLES_HOLOVIZ_AE5_USERNAME }} | |
EXAMPLES_HOLOVIZ_AE5_PASSWORD: ${{ secrets.EXAMPLES_HOLOVIZ_AE5_PASSWORD }} | |
jobs: | |
inferprojects: | |
if: | | |
(github.event_name == 'pull_request' && github.event.pull_request.merged == true) || | |
github.event_name == 'workflow_dispatch' || | |
github.event_name == 'schedule' | |
name: Deploy on Merge | |
runs-on: 'ubuntu-latest' | |
defaults: | |
run: | |
shell: bash -el {0} | |
outputs: | |
changedprojects: ${{ steps.set-projects.outputs.changedprojects }} | |
removedprojects: ${{ steps.set-projects.outputs.removedprojects }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Needed to compute the diff between the head and the latest commit on main | |
fetch-depth: 2 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniconda-version: "latest" | |
auto-activate-base: false | |
activate-environment: examples-gallery-manage | |
environment-file: envs/environment-ubuntu-latest.lock | |
- name: infer projects list | |
id: set-projects | |
run: | | |
EVENTNAME="${{ github.event_name }}" | |
ALL="${{ inputs.all }}" | |
# IMPORTANT: the single quote here matters to preserve the JSON structure of the data | |
INPUTS='${{ inputs.projects }}' | |
if [ "$EVENTNAME" == "pull_request" ]; then | |
CHANGES=$(doit util_list_changed_dirs_with_last_commit --exclude-website-metadata --exclude-test-data | tail -n -1) | |
CHANGEDPROJECTS=$(echo $CHANGES | jq -c -r '.changed') | |
REMOVEDPROJECTS=$(echo $CHANGES | jq -c -r '.removed') | |
if [ "$CHANGEDPROJECTS" != "[]" -a "$REMOVEDPROJECTS" != "[]" ]; then | |
echo "No support for removing and updating projects together" | |
echo "Open a PR that just remove project" | |
exit 1 | |
fi | |
elif [ "$EVENTNAME" == "workflow_dispatch" ]; then | |
if [ "$ALL" == "true" ]; then | |
CHANGEDPROJECTS=$(doit util_list_project_dir_names | tail -n -1) | |
else | |
echo "$INPUTS" > .projects | |
CHANGEDPROJECTS=$(doit util_list_comma_separated_projects | tail -n -1) | |
rm .projects | |
fi | |
REMOVEDPROJECTS="[]" | |
elif [ "$EVENTNAME" == "schedule" ]; then | |
CHANGEDPROJECTS='["template"]' | |
REMOVEDPROJECTS="[]" | |
fi | |
echo "Changed projects:" | |
echo $CHANGEDPROJECTS | |
echo "Removed projects:" | |
echo $REMOVEDPROJECTS | |
echo "CHANGEDPROJECTS=$CHANGEDPROJECTS" >> $GITHUB_OUTPUT | |
echo "REMOVEDPROJECTS=$REMOVEDPROJECTS" >> $GITHUB_OUTPUT | |
deploy_matrix: | |
needs: inferprojects | |
if: needs.inferprojects.outputs.changedprojects != '[]' | |
name: Deployments | |
strategy: | |
fail-fast: false | |
matrix: | |
changedproject: ${{ fromJson(needs.inferprojects.outputs.changedprojects) }} | |
uses: ./.github/workflows/deploy_one.yml | |
with: | |
changedproject: ${{ matrix.changedproject }} | |
secrets: inherit | |
remove_matrix: | |
needs: inferprojects | |
if: github.event_name == 'pull_request' && needs.inferprojects.outputs.removedprojects != '[]' | |
name: Removals | |
strategy: | |
fail-fast: false | |
matrix: | |
removedproject: ${{ fromJson(needs.inferprojects.outputs.removedprojects) }} | |
uses: ./.github/workflows/deploy_one.yml | |
with: | |
removedproject: ${{ matrix.removedproject }} | |
secrets: inherit |