Skip to content

Deploy Somnia from artifact created by "resolves #2053 (#2481)" #361

Deploy Somnia from artifact created by "resolves #2053 (#2481)"

Deploy Somnia from artifact created by "resolves #2053 (#2481)" #361

Workflow file for this run

name: Deploy Somnia from artifact
run-name: Deploy Somnia from artifact created by "${{ github.event.workflow_run.display_title }}"
on:
workflow_run:
workflows:
- Build Somnia
types:
- completed
jobs:
set-env:
runs-on: ubuntu-latest
outputs:
env: ${{ steps.set_env.outputs.env }}
shouldDeploy: ${{ steps.set_env.outputs.shouldDeploy }}
prNumber: ${{ steps.set_env.outputs.prNumber }}
ref: ${{ steps.set_env.outputs.ref }}
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set env
id: set_env
run: |
echo "env=$(cat somnia_build/environment)" >> $GITHUB_OUTPUT
echo "shouldDeploy=$(cat somnia_build/shouldDeploy)" >> $GITHUB_OUTPUT
echo "prNumber=$(cat somnia_build/prNumber)" >> $GITHUB_OUTPUT
echo "ref=$(cat somnia_build/ref)" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: set-env
environment:
name: ${{ needs.set-env.outputs.env }}
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write # This is required for requesting the JWT
if: ${{ github.event.workflow_run.conclusion == 'success' && (needs.set-env.outputs.shouldDeploy == 'true' || needs.set-env.outputs.env == 'somnia-prod') }}
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Setup config.json and others
run: |
printf '%s' "$CONFIG" > somnia_build/dist/apps/somnia/apps/somnia/src/config.json
echo ${{ needs.set-env.outputs.ref }} > somnia_build/dist/apps/somnia/ref
echo ${{ needs.set-env.outputs.prNumber }} > somnia_build/dist/apps/somnia/prNumber
env:
CONFIG: ${{ secrets.SOMNIA_CREDENTIALS }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ needs.set-env.outputs.env }}
slot-name: 'Production'
package: somnia_build/dist/apps/somnia
- name: Output date
id: output-date
run: echo "date=$(date -u)" >> $GITHUB_OUTPUT
- name: Maintain comment
uses: actions-cool/maintain-one-comment@v3
if: ${{ needs.set-env.outputs.prNumber != '' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ needs.set-env.outputs.prNumber }}
body: |
[${{ needs.set-env.outputs.env }}] [${{ steps.output-date.outputs.date }}] - Deployed ${{ needs.set-env.outputs.ref }} to ${{ needs.set-env.outputs.env }}" >> $GITHUB_OUTPUT
body-include: '<!-- Created by actions-cool/maintain-one-comment -->'
update-mode: 'append'