Restructure repo (#15) #59
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
name: Build Actions Runner | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- src/images/github-runner-linux/** | |
- src/images/github-runner-win/** | |
- src/infrastructure/acr/** | |
workflow_dispatch: | |
inputs: | |
buildLinuxRunner: | |
description: 'Build Linux Runner' | |
type: boolean | |
required: true | |
default: true | |
buildWindowsRunner: | |
description: 'Build Windows Runner' | |
type: boolean | |
required: true | |
default: true | |
env: | |
AZURE_LOCATION: australiaeast | |
ACR_ROOT: ${{ github.workspace }}/src/infrastructure/acr | |
LNX_RUNNER_ROOT: ${{ github.workspace }}/src/images/github-runner-linux | |
WIN_RUNNER_ROOT: ${{ github.workspace }}/src/images/github-runner-win | |
LNX_IMAGE_NAME: github-runners/github-runner-linux-amd64 | |
WIN_IMAGE_NAME: github-runners/github-runner-win-amd64 | |
IMAGE_VERSION: 1.0.0.${{ github.run_number }} | |
AZURE_RG: ${{ vars.ENV_AZURE_RG }} | |
ACR_NAME: ${{ vars.ENV_ACR_NAME }} | |
ACR_SERVER: ${{ vars.ENV_ACR_NAME }}.azurecr.io | |
jobs: | |
deployInfra: | |
name: Deploy Infra | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Login to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.ENV_AZURE_CREDENTIALS }} | |
- name: Create RG | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
if [[ $(az group exists --name $AZURE_RG) == true ]]; then | |
echo "Resource group already exists." | |
else | |
az group create --name $AZURE_RG --location $AZURE_LOCATION | |
fi | |
- name: Run PSRule | |
uses: ./.github/actions/ps-rule | |
with: | |
TEMPLATE_NAME: ACR | |
INPUT_PATH: ${{ env.ACR_ROOT }}/.test | |
- name: Deploy ACR | |
uses: ./.github/actions/deploy-acr | |
with: | |
AZURE_CREDENTIALS: ${{ secrets.ENV_AZURE_CREDENTIALS }} | |
ROOT: ${{ env.ACR_ROOT }} | |
AZURE_RG: ${{ env.AZURE_RG }} | |
ACR_NAME: ${{ env.ACR_NAME }} | |
publishLinux: | |
name: Publish Linux Image | |
runs-on: ubuntu-latest | |
needs: deployInfra | |
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || inputs.buildLinuxRunner }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build Runner | |
uses: ./.github/actions/github-runner-build | |
with: | |
AZURE_CREDENTIALS: ${{ secrets.ENV_AZURE_CREDENTIALS }} | |
ACR_NAME: ${{ env.ACR_NAME }} | |
RUNNER_ROOT: ${{ env.LNX_RUNNER_ROOT }} | |
IMAGE_NAME: ${{ env.LNX_IMAGE_NAME }} | |
IMAGE_VERSION: ${{ env.IMAGE_VERSION }} | |
ACR_SERVER: ${{ env.ACR_SERVER }} | |
publishWindows: | |
name: Publish Windows Image | |
runs-on: windows-latest | |
needs: deployInfra | |
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || inputs.buildWindowsRunner }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build Runner | |
uses: ./.github/actions/github-runner-build | |
with: | |
AZURE_CREDENTIALS: ${{ secrets.ENV_AZURE_CREDENTIALS }} | |
ACR_NAME: ${{ env.ACR_NAME }} | |
RUNNER_ROOT: ${{ env.WIN_RUNNER_ROOT }} | |
IMAGE_NAME: ${{ env.WIN_IMAGE_NAME }} | |
IMAGE_VERSION: ${{ env.IMAGE_VERSION }} | |
ACR_SERVER: ${{ env.ACR_SERVER }} |