Skip to content

Commit

Permalink
Merge pull request #308 from microsoft/dev
Browse files Browse the repository at this point in the history
rework release workflow
  • Loading branch information
colbylwilliams authored Feb 1, 2022
2 parents 4c972fb + b46d97f commit 8e8fb04
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 257 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/deploy_demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Deploy Demo

on:
workflow_dispatch:
inputs:
tag:
required: false
description: 'Tag to release.'
reset_demo:
required: false
description: 'Reset the demo environment.'
default: 'false'

jobs:
build:
name: Deploy Demo
runs-on: ubuntu-latest

steps:
- name: Resolve Tag
id: resolve-tag
uses: actions/github-script@v4
with:
result-encoding: string
script: |
let tag = '${{ github.event.inputs.tag }}';
if (!tag) {
const parts = context.ref.split('/');
if (!parts.includes('tags'))
throw new Error(`ref ${context.ref} is not a tag.`);
tag = parts[parts.length - 1];
}
console.log(`Resolved tag: ${tag}`);
return tag;
- name: Get Release
id: get-release
uses: actions/github-script@v4
with:
script: |
let tag = '${{steps.resolve-tag.outputs.result}}';
const release = await github.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
console.log(release.data);
return release.data;
- name: Get CLI Release Asset
id: get-cli
uses: actions/github-script@v4
with:
result-encoding: string
script: |
const release = JSON.parse('${{steps.get-release.outputs.result}}');
const cli_asset = release.assets.find(a => a.browser_download_url.includes('py3-none-any.whl'));
if (!cli_asset)
throw new Error('Could not find cli wheel file in release assets');
const cli_url = cli_asset.browser_download_url;
console.log(cli_url);
return cli_url;
- name: Login to Azure
run: |
echo "logging in to azure cli"
az login --service-principal -u ${{ secrets.TEAMCLOUD_CI_USERNAME }} -p ${{ secrets.TEAMCLOUD_CI_PASSWORD }} --tenant ${{ secrets.TEAMCLOUD_CI_TENANT }}
- name: Install az util extension
if: github.event.inputs.reset_demo == 'true'
run: |
az extension add -s https://github.com/colbylwilliams/az-util/releases/latest/download/util-0.1.2-py2.py3-none-any.whl -y
- name: Guard Demo environment
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Reset Demo environment
if: github.event.inputs.reset_demo == 'true'
run: |
while read SUBSCRIPTIONID; do
echo "Cleaning up subscripton '$( az account show --subscription $SUBSCRIPTIONID --query name -o tsv )'"
az util group delete --subscription $SUBSCRIPTIONID --prefix T --skip TeamCloud-Registry
az util keyvault purge --subscription $SUBSCRIPTIONID
done < <( az account list --refresh --only-show-errors --query "[?(starts_with(@.name, 'TeamCloud DEMO'))].id" -o tsv )
- name: Deploy Demo environment
run: |
echo "installing teamcloud cli extension"
az extension add -s ${{steps.get-cli.outputs.result}} -y
echo "deploying demo teamcloud instance"
az tc deploy --subscription ${{ secrets.TEAMCLOUD_SUBSCRIPTION }} -l eastus --principal-name ${{ secrets.TEAMCLOUD_RM_USERNAME }} --principal-password ${{ secrets.TEAMCLOUD_RM_PASSWORD }} --client-id ${{ secrets.TEAMCLOUD_WEB_USERNAME }} --scope ${{ secrets.TEAMCLOUD_WEB_SCOPE }} -v ${{steps.resolve-tag.outputs.result}} --skip-name-validation -n teamclouddemo
- name: Logout Azure CLI
if: ${{ always() }}
run: az logout
175 changes: 0 additions & 175 deletions .github/workflows/pre_release.yml

This file was deleted.

Loading

0 comments on commit 8e8fb04

Please sign in to comment.