Pr env #3
Workflow file for this run
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
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | |
# More GitHub Actions for Azure: https://github.com/Azure/actions | |
name: Deploy PR | |
on: | |
pull_request: | |
types: [opened, edited, reopened] | |
branches: master | |
env: | |
AZURE_WEBAPP_NAME: gccollab-dev-pr-${{ github.event.number }} | |
AZURE_WEBAPP_PACKAGE_PATH: './dist/gccollab-frontend' | |
NODE_VERSION: '16.14.2' | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
jobs: | |
setup: | |
name: Setup Environemnt w/ Bicep | |
runs-on: ubuntu-latest | |
steps: | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Create Resource Group | |
uses: azure/arm-deploy@v1 | |
with: | |
scope: 'subscription' | |
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} | |
template: ./.bicep/pr-instance-setup.bicep | |
parameters: 'storagePrefix=mystore storageSKU=Standard_LRS' | |
failOnStdErr: false | |
- name: Create Web App and Service | |
uses: azure/arm-deploy@v1 | |
with: | |
scope: 'resourcegroup' | |
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} | |
resourceGroupName: ${{ env.AZURE_WEBAPP_NAME }} | |
template: ./.bicep/pr-instance.bicep | |
parameters: 'storagePrefix=mystore storageSKU=Standard_LRS' | |
failOnStdErr: false | |
store: | |
name: Store Publishing Profile | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Get Publishing Profile | |
id: get-publishing-profile | |
run: | | |
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION }} | |
profile=$(az webapp deployment list-publishing-profiles --resource-group ${{ env.AZURE_WEBAPP_NAME }} --name ${{ env.AZURE_WEBAPP_NAME }} --xml | sed -e 's|\"<|<|g' | sed -e 's|>\"|>|g' | sed -e 's|\\"|"|g' | sed -e 's|\\\\|\\|g') | |
echo "::set-output name=profile::$profile" | |
- name: GitHub Auth Login | |
shell: bash | |
run: gh auth login --with-token <<< ${{ env.ACCESS_TOKEN }} | |
- name: Create Secret | |
run: | | |
echo "$PROFILE" > profile.txt | |
gh secret set "${{ env.AZURE_WEBAPP_NAME }}" --in-file profile.txt --repo $repository | |
env: | |
PROFILE: ${{ steps.get-publishing-profile.outputs.profile }} | |
create-environment: | |
name: Create Environment | |
runs-on: ubuntu-latest | |
needs: [setup, store] | |
steps: | |
- name: Create Environment | |
shell: bash | |
run: | | |
curl -X POST "https://api.github.com/repos/gctools-outilsgc/gccollab-frontend/environments" \ | |
-H "Authorization: token ${{ env.ACCESS_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-d "{\"name\":\"PR ${{ github.event.number }}\"}" | |
build-test-and-deploy: | |
name: Build, Test and Deploy | |
runs-on: windows-latest | |
needs: [setup, store, create-environment] | |
environment: | |
name: PR ${{ github.event.number }} | |
url: https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net/ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install | |
run: npm install | |
- name: Build | |
run: npm run build-dev --if-present | |
- name: Test | |
run: npm run test --if-present -- --watch=false --browsers=ChromeHeadless | |
- name: 'Deploy to Azure WebApp' | |
uses: azure/webapps-deploy@v1 | |
with: | |
app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
publish-profile: ${{ secrets[env.AZURE_WEBAPP_NAME] }} | |
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |