MuzakBot / Create container images #86
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow | |
name: MuzakBot / Create container images | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
workflow_dispatch: | |
inputs: | |
push: | |
description: "Push to container registry" | |
required: false | |
default: true | |
type: boolean | |
deployToAzure: | |
description: "Deploy to Azure" | |
required: false | |
default: true | |
type: boolean | |
permissions: | |
packages: write | |
contents: read | |
jobs: | |
create-muzakbot-image: | |
name: Create MuzakBot image | |
runs-on: ubuntu-latest | |
outputs: | |
image: ${{ steps.output_image.outputs.image }} | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.actor }}/MuzakBot | |
tags: | | |
type=ref,event=tag | |
type=ref,event=branch | |
type=sha | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Build and push Docker image | |
id: image_build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
file: ./Dockerfile.MuzakBot | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name == 'push' && true || github.event.inputs.push }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
"NUGET_USER=${{ github.repository_owner }}" | |
"NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }}" | |
- name: Set output image | |
id: output_image | |
shell: pwsh | |
run: | | |
$repoOwner = "${{ github.repository_owner }}".ToLower() | |
$imageDigest = "${{ steps.image_build.outputs.digest }}" | |
"image=ghcr.io/$($repoOwner)/muzakbot@$($imageDigest)" >> $env:GITHUB_OUTPUT | |
deploy-muzakbotto-azure: | |
name: Deploy MuzakBot to Azure | |
runs-on: ubuntu-latest | |
needs: create-muzakbot-image | |
environment: Production | |
if: ${{ github.event_name == 'push' || github.event.inputs.deployToAzure == true }} | |
permissions: | |
id-token: write | |
steps: | |
- name: Log into Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Deploy to Azure Container Apps | |
uses: azure/container-apps-deploy-action@v2 | |
with: | |
containerAppName: ${{ secrets.AZURE_CONTAINER_APP_NAME }} | |
resourceGroup: ${{ secrets.AZURE_CONTAINER_RESOURCE_GROUP_NAME }} | |
imageToDeploy: ${{ needs.create-muzakbot-image.outputs.image }} | |
create-webapp-image: | |
name: Create WebApp image | |
runs-on: ubuntu-latest | |
needs: create-muzakbot-image | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.actor }}/MuzakBot-WebApp | |
tags: | | |
type=ref,event=tag | |
type=ref,event=branch | |
type=sha | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
file: ./Dockerfile.WebApp | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name == 'push' && true || github.event.inputs.push }} | |
cache-from: type=gha | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
"NUGET_USER=${{ github.repository_owner }}" | |
"NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }}" | |
create-geniusservice-image: | |
name: Create GeniusService image | |
runs-on: ubuntu-latest | |
needs: create-muzakbot-image | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.actor }}/MuzakBot-GeniusService | |
tags: | | |
type=ref,event=tag | |
type=ref,event=branch | |
type=sha | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
file: ./Dockerfile.GeniusService | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name == 'push' && true || github.event.inputs.push }} | |
cache-from: type=gha | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
"NUGET_USER=${{ github.repository_owner }}" | |
"NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }}" |