Skip to content

Build on Self Hosted Agent #190

Build on Self Hosted Agent

Build on Self Hosted Agent #190

name: Build on Self Hosted Agent
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- develop
- hotfix/*
schedule:
- cron: '0 7 * * WED'
jobs:
start-azure-vm:
name: Start Azure Agent
runs-on: ubuntu-latest
steps:
- if: github.ref == 'refs/heads/main'
name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- if: github.ref == 'refs/heads/main'
name: Azure CLI script file
uses: azure/CLI@v1
with:
inlineScript: |
az vm start --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --name ${{ secrets.AZURE_RESOURCE_VMNAME }} --verbose
build-self-hosted:
name: Build Images
needs: start-azure-vm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [self-hosted]
sdk: ['6.0', '7.0']
steps:
- if: github.ref == 'refs/heads/main'
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get the sources
uses: actions/checkout@v3
- name: Run Cake script
uses: cake-build/cake-action@master
env:
GITHUB_TOKEN: ${{ github.token }}
with:
cake-version: tool-manifest
arguments: |
base-image-include-filter: ${{ matrix.sdk }}-nanoserver-1
base-image-include-filter: ${{ matrix.sdk }}-nanoserver-2
stop-azure-vm:
name: Stop Azure Agent
needs: build-self-hosted
runs-on: ubuntu-latest
steps:
- if: github.ref == 'refs/heads/main'
name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- if: github.ref == 'refs/heads/main'
name: Azure CLI script file
uses: azure/CLI@v1
with:
inlineScript: |
az vm deallocate --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --name ${{ secrets.AZURE_RESOURCE_VMNAME }} --verbose