Skip to content

DemoServerUp

DemoServerUp #355

name: DemoServerUp
on:
workflow_dispatch:
# CONFIGURATION
# For help, go to https://github.com/Azure/Actions
#
# 1. Set up the following secrets in your repository:
# AZURE_WEBAPP_PUBLISH_PROFILE
#
# 2. Change these variables for your configuration:
env:
ICM_BASE_URL: https://icm-design-view.test.intershop.com
jobs:
CancelPrevious:
runs-on: ubuntu-latest
steps:
- name: Cancel Old Pipeline
uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-deploy:
needs: [CancelPrevious]
if: github.event.repository.full_name == 'intershop/intershop-pwa'
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish SSR image to Registry
id: ssr
uses: elgohr/Publish-Docker-Github-Action@v5
env:
serviceWorker: false
displayVersion: ${{ github.event.after }}
testing: true
NODE_OPTIONS: --max_old_space_size=8192
with:
name: intershop-pwa-ssr
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
buildargs: serviceWorker,displayVersion,testing
- name: Publish NGINX image to Registry
id: nginx
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: intershop-pwa-nginx
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
context: nginx
- name: Set Environment
run: |
echo "BRANCH_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "DOCKER_IMAGE_SSR=${{ steps.ssr.outputs.digest }}" >> $GITHUB_ENV
echo "DOCKER_IMAGE_NGINX=${{ steps.nginx.outputs.digest }}" >> $GITHUB_ENV
printf 'AZURE_WEBAPP_NAME=%.60s' "${{ secrets.AZURE_DEMO_RESOURCEGROUP }}-$( echo ${{ github.event.ref }} | sed -e 's/refs\/heads\///' | sed -e 's/[^a-zA-Z0-9-]/-/g' )" >> $GITHUB_ENV
- name: Login via Azure CLI
run: az login --service-principal --username ${{ secrets.AZURE_SP_USERNAME }} --password ${{ secrets.AZURE_SP_PASSWORD }} --tenant ${{ secrets.AZURE_SP_TENANT }}
- name: Create or Update containerized WebApp
env:
APP: ${{ env.AZURE_WEBAPP_NAME }}
GROUP: ${{ secrets.AZURE_DEMO_RESOURCEGROUP }}
run: |
set -ex
pip install -r ./.github/scripts/requirements.txt
python ./.github/scripts/docker-compose.py $ICM_BASE_URL "$DOCKER_IMAGE_SSR" "$DOCKER_IMAGE_NGINX"
az webapp config container set --resource-group $GROUP --name $APP --multicontainer-config-type compose --multicontainer-config-file dist/docker-compose.yml || az webapp create --resource-group $GROUP --plan ${{ secrets.AZURE_DEMO_APPSERVICEPLAN }} --name $APP --multicontainer-config-type compose --multicontainer-config-file dist/docker-compose.yml
az webapp config container set --docker-registry-server-password ${{ secrets.DOCKER_REGISTRY_PASSWORD }} --docker-registry-server-url ${{ secrets.DOCKER_REGISTRY }} --docker-registry-server-user ${{ secrets.DOCKER_REGISTRY_USERNAME }} --name $APP --resource-group $GROUP
- name: Find Pull Request
uses: juliangruber/find-pull-request-action@v1
id: find-pull-request
with:
branch: ${{ env.BRANCH_NAME }}
- name: Found Pull Request
run: echo "Pull Request for Branch ${{ env.BRANCH_NAME }} -> ${{ steps.find-pull-request.outputs.number }} (${{ steps.find-pull-request.outputs.head-sha }})"
- name: Create Demo Server Comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ steps.find-pull-request.outputs.number }}
body: |
Azure Demo Servers are available:
- [Universal B2B](https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net/en/home)
- [Universal B2C](https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net/b2c/home)