-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
64 additions
and
27 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,88 @@ | ||
name: build | ||
|
||
env: | ||
DB_TOKEN: ${{ secrets.DB_TOKEN }} | ||
DB_HOST: ${{ secrets.DB_HOST }} | ||
GH_TOKEN: ${{ github.token }} | ||
name: publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
repository_path: | ||
description: 'Repository path on [$DB_HOST] environment' | ||
required: true | ||
solution_name: | ||
description: 'Code name of the solution accelerator' | ||
environment: | ||
type: choice | ||
description: 'Databricks environment to publish HTML from' | ||
options: | ||
- e2-demo-field-eng.cloud.databricks.com | ||
- e2-demo-west.cloud.databricks.com | ||
- 6177827686947384.4.gcp.databricks.com | ||
path: | ||
type: string | ||
description: 'Repository path on databricks environment' | ||
required: true | ||
|
||
permissions: | ||
contents: write | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
tests: | ||
env: | ||
PYTHON: '3.9' | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
|
||
- name: Checkout project | ||
uses: actions/checkout@v2 | ||
|
||
- name: Unshallow | ||
run: git fetch --prune --unshallow | ||
- name: Configure git | ||
run: | | ||
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | ||
git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)" | ||
- name: Retrieve latest site | ||
run: | | ||
git subtree split --prefix site/ -b gh-pages | ||
git push -f origin gh-pages:gh-pages | ||
git branch -D gh-pages | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Configure Python | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
${{ runner.os }}-pip- | ||
- name: Install pip | ||
run: python -m pip install --upgrade pip | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install git+https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/databricks-industry-solutions/industry-solutions-release | ||
run: pip install -U -r requirements.txt | ||
|
||
- name: Publish solution accelerator | ||
run: | | ||
from databricks.accelerator import Accelerator | ||
import os | ||
db_path = ${{ github.event.inputs.repository_path }} | ||
db_name = ${{ github.event.inputs.solution_name }} | ||
print(f'Publishing solution [{db_name}]') | ||
accelerator = Accelerator(db_host=os.environ['DB_HOST'], db_token=os.environ['DB_TOKEN']) | ||
accelerator.release(db_path, db_name) | ||
shell: python | ||
db_host = ${{ github.event.inputs.environment }} | ||
if db_host == 'e2-demo-field-eng.cloud.databricks.com': | ||
db_token = ${{ secrets.DB_AWS_FIELD_TOKEN }} | ||
elif db_host == 'e2-demo-west.cloud.databricks.com': | ||
db_token = ${{ secrets.DB_AWS_DEMO_TOKEN }} | ||
elif db_host == '6177827686947384.4.gcp.databricks.com': | ||
db_token = ${{ secrets.DB_GCP_TOKEN }} | ||
else: | ||
exit(1) | ||
from databricks.solution import Accelerator | ||
Accelerator( | ||
db_host=db_host, | ||
db_token=db_token, | ||
db_path=${{ github.event.inputs.path }}, | ||
db_name=${{ github.event.repository.name }}, | ||
).release() | ||
shell: python |