Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Action to automated deployment testing #467

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1cd73ec
Create test-deploy.yml
DanielLarsenNZ May 23, 2022
5c86487
Fix GH action
DanielLarsenNZ May 23, 2022
58d62d7
Fix GH action
DanielLarsenNZ May 23, 2022
3d1227d
Testing GH action
DanielLarsenNZ May 23, 2022
47f73ec
Test deploy GH Action
DanielLarsenNZ May 23, 2022
50f0499
gh action cd to file path
DanielLarsenNZ May 23, 2022
b840882
test the action
DanielLarsenNZ May 23, 2022
d9ee991
test the action
DanielLarsenNZ May 23, 2022
9821124
suppress resource group delete error
DanielLarsenNZ May 24, 2022
fc1de87
delete RG if exists
DanielLarsenNZ May 24, 2022
4d550df
Fix action
DanielLarsenNZ May 24, 2022
b5b468e
Fix GH test deploy action
DanielLarsenNZ May 24, 2022
bab194b
Fix resource group env var
DanielLarsenNZ May 24, 2022
5bb6e25
Fix resource group env var
DanielLarsenNZ May 24, 2022
4114456
Tidy up GH action
DanielLarsenNZ May 24, 2022
55c491e
echo out git diff
DanielLarsenNZ May 26, 2022
d00db36
echo out git diff
DanielLarsenNZ May 26, 2022
768f841
fixing workflow
DanielLarsenNZ May 26, 2022
450de3c
fixing workflow
DanielLarsenNZ May 27, 2022
926e75c
Update test-deploy.yml
DanielLarsenNZ May 27, 2022
d5a69ab
Update test-deploy.yml
DanielLarsenNZ May 27, 2022
357b147
Update test-deploy.yml
DanielLarsenNZ May 27, 2022
c2a3d8c
Tidy up workflow
DanielLarsenNZ May 27, 2022
139dd9d
Fix cd => pushd
DanielLarsenNZ May 27, 2022
3f14a6c
Don't run deleted files
DanielLarsenNZ May 27, 2022
515977f
Update test-deploy.yml
DanielLarsenNZ May 27, 2022
29d0230
Update test-deploy.yml
DanielLarsenNZ May 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test & Deploy

on:
pull_request:
branches: [ master ]
paths:
- '**.sh'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
environment: 'AzureCloud'

- name: Run any shell scripts in this commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
az config set extension.use_dynamic_install=yes_without_prompt

echo "===================================="
echo "Files in PR ${{ github.head_ref }}:"
gh pr view ${{ github.head_ref }} --json files -q '.files[].path'

# For each file in this commit
for file in $( gh pr view ${{ github.head_ref }} --json files -q '.files[].path' )
do
# If file exists and is shell script
if [ -e "$file" ]
then
if [[ "$file" == *.sh ]]
then
# Generate a resource group name so that it can be deleted when finished
let "randomIdentifier=$RANDOM*$RANDOM"
resourceGroup="test-deploy-rg-$randomIdentifier"

echo "===================================="
echo "Running $file ..."
pushd $(dirname "${file}")
chmod +X $(basename "${file}")
RESOURCE_GROUP=$resourceGroup /bin/bash $(basename "${file}")
popd
echo "===================================="

# Clean up the resource group
if [ $(az group exists --name $resourceGroup) = true ]; then
echo "Deleting resource group $resourceGroup..."
az group delete -n $resourceGroup -y --no-wait
fi
fi
fi
done
10 changes: 9 additions & 1 deletion azure-front-door/deploy-custom-domain/deploy-custom-domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ set -e
# Change these hardcoded values if required

let "randomIdentifier=$RANDOM*$RANDOM"

# Use resource group environment variable if set
if [ "$RESOURCE_GROUP" == '' ];
then
resourceGroup="msdocs-frontdoor-rg-$randomIdentifier"
else
resourceGroup="${RESOURCE_GROUP}"
fi

location='AustraliaEast'
resourceGroup="msdocs-frontdoor-rg-$randomIdentifier"
tag='deploy-custom-domain'

storage="msdocsafd$randomIdentifier"
Expand Down