Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/0-welcome.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Step 0, Welcome
name: Welcome to Auto Deploy Azure

# This step triggers after the learner creates a new repository from the template
# This workflow updates from step 0 to step 1.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/1-configure-label-based-job.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Step 1, Trigger a job based on labels
name: Trigger Deployments by Label

# This step triggers after 0-start.yml.
# This workflow updates from step 1 to step 2.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/2-setup-azure-environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Step 2, Set up the Azure environment
name: Step 2 · Initialize Azure Infrastructure

# This workflow updates from step 2 to step 3.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/3-spinup-environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Step 3, Spin up environment
name: Step 3 · Spin Up Staging Infrastructure

# This workflow updates from step 3 to step 4.

Expand Down
26 changes: 7 additions & 19 deletions .github/workflows/4-deploy-to-staging-environment.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
name: Step 4, Deploy to staging
name: Step 4 · Deploy App to Staging Environment

# This workflow updates from step 4 to step 5.

# This will run after the "Deploy to staging" workflow
# completes on the staging-test branch
# completes on the staging-test-env branch
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
workflow_dispatch:
workflow_run:
workflows: ["Deploy to staging"]
types: [completed]
branches: [staging-test]
branches: [staging-test-env]

permissions:
# Need `contents: read` to checkout the repository.
# Need `contents: write` to update the step metadata.
contents: write
pull-requests: write

jobs:
# Get the current step to only run the main job when the learner is on the same step.
get_current_step:
name: Check current step number
runs-on: ubuntu-latest
Expand All @@ -36,42 +33,33 @@ jobs:
name: On Azure environment created
needs: get_current_step
runs-on: ubuntu-latest

# We will only run this action when:
# 1. This repository isn't the template repository.
# 2. The step is currently 4.
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 4 }}

steps:
# We'll need to check out the repository so that we can edit the README.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Let's get all the branches.
fetch-depth: 0

# Merge the pull open pull request
- name: Merge Pull Request
run: gh pr merge --squash staging-test
run: gh pr merge --squash staging-test-env
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Pull main.
- name: Pull main
run: |
chmod +x ./.github/script/initialize-repository.sh
./.github/script/initialize-repository.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# In README.md, switch step 4 for step 5.
- name: Update to step 5
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 4
to_step: 5
branch_name: staging-test
branch_name: staging-test-env

30 changes: 8 additions & 22 deletions .github/workflows/5-deploy-to-prod-environment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Step 5, Test the deploy to staging workflow
name: Step 5 · Confirm Staging Deployment Triggers Correctly

# This step triggers after a pull requst is merged to `main`.
# This step triggers after a pull request is merged to `main`.

# This will run after the "Deploy to production"" workflow
# completes on the production-deployment-workflow branch
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
# It runs after the "Deploy to production" workflow completes
# on the `prod-deploy` branch.
on:
workflow_dispatch:
workflow_run:
Expand All @@ -13,12 +12,9 @@ on:
branches: [main]

permissions:
# Need `contents: read` to checkout the repository.
# Need `contents: write` to update the step metadata.
contents: write

jobs:
# Get the current step to only run the main job when the learner is on the same step.
get_current_step:
name: Check current step number
runs-on: ubuntu-latest
Expand All @@ -34,30 +30,20 @@ jobs:
on_deploy_to_prod:
name: On deploy to production
needs: get_current_step

# We will only run this action when:
# 1. This repository isn't the template repository.
# 2. The step is currently 5.
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 5 }}

# We'll run Ubuntu for performance instead of Mac or Windows.
runs-on: ubuntu-latest

steps:
# We'll need to check out the repository so that we can edit the README.
- name: Checkout
- name: Checkout all branches
uses: actions/checkout@v4
with:
fetch-depth: 0 # Let's get all the branches.
fetch-depth: 0

# In README.md, switch step 5 for step 6.
- name: Update to step 6
- name: Promote to step 6 in README
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 5
to_step: 6

36 changes: 11 additions & 25 deletions .github/workflows/6-destroy-azure-environment.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
name: Step 6, Production deployment cleanup
name: Step 6 · Cleanup After Production Deployment

# This workflow updates from step 6 to step X.
# This workflow updates from step 6 to step 7 (wrap-up or future step)

# This will run after the "Configure Azure environment" workflow
# completes on the production-deployment-workflow branch
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
# It triggers after the "Configure Azure environment" workflow completes
# on the `prod-deploy` branch.
on:
workflow_dispatch:
workflow_run:
workflows: ["Configure Azure environment"]
types: [completed]
branches: [production-deployment-workflow]
branches: [prod-deploy]

permissions:
# Need `contents: read` to checkout the repository.
# Need `contents: write` to update the step metadata.
contents: write

jobs:
# Get the current step to only run the main job when the learner is on the same step.
get_current_step:
name: Check current step number
runs-on: ubuntu-latest
Expand All @@ -32,32 +28,22 @@ jobs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_destroy_completed:
name: On destroy completed
name: Cleanup Completed · Finalize Progress
needs: get_current_step

# We will only run this action when:
# 1. This repository isn't the template repository.
# 2. The step is currently 6.
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 6 }}

# We'll run Ubuntu for performance instead of Mac or Windows.
runs-on: ubuntu-latest

steps:
# We'll need to check out the repository so that we can edit the README.
- name: Checkout
- name: Checkout All Branches
uses: actions/checkout@v4
with:
fetch-depth: 0 # Let's get all the branches.
fetch-depth: 0

# In README.md, switch step 6 for step X.
- name: Update to step X
- name: Promote to Step 7
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 6
to_step: X
to_step: 7

73 changes: 40 additions & 33 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Deploy to production
name: 🚀 Auto Deploy Azure - Production

# This workflow automatically deploys to production when changes are merged to main
# No manual label is required like in the staging workflow
# Automatically deploys to Azure when pushing to the `main` branch

on:
push:
Expand All @@ -10,94 +9,102 @@

env:
IMAGE_REGISTRY_URL: ghcr.io
###############################################
### Replace <username> with GitHub username ###
###############################################
DOCKER_IMAGE_NAME: msalsouri-azure-ttt
AZURE_WEBAPP_NAME: msalsouri-ttt-app
###############################################
DOCKER_IMAGE_NAME: ${{ github.repository_owner }}-${{ github.event.repository.name }}
AZURE_WEBAPP_NAME: ${{ github.repository_owner }}-${{ github.event.repository.name }}-app

jobs:
build:
name: 🛠 Build Frontend
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: npm install and build webpack

- name: Install & Build Webpack
run: |
npm install
npm ci
npm run build
- uses: actions/upload-artifact@v4

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: webpack artifacts
name: webpack-artifacts
path: public/

Build-Docker-Image:
docker_build:

Check warning on line 40 in .github/workflows/deploy-prod.yml

View check run for this annotation

GitHub Advanced Security / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions
Comment on lines +17 to +40

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions Job or Workflow does not set permissions
name: 🐳 Build & Push Docker Image
runs-on: ubuntu-latest
needs: build
name: Build image and store in GitHub Container Registry

steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4

- name: Download built artifact
- name: Download Webpack Artifacts
uses: actions/download-artifact@v4
with:
name: webpack artifacts
name: webpack-artifacts
path: public

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY_URL }}
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}

- name: Extract metadata (tags, labels) for Docker
- name: Extract Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{env.IMAGE_REGISTRY_URL}}/${{ github.repository }}/${{env.DOCKER_IMAGE_NAME}}
images: ${{ env.IMAGE_REGISTRY_URL }}/${{ github.repository }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=sha,format=long,prefix=

- name: Build and push Docker image
- name: Build & Push Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Deploy-to-Azure:
deploy:

Check warning on line 78 in .github/workflows/deploy-prod.yml

View check run for this annotation

GitHub Advanced Security / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions Job or Workflow does not set permissions
name: ☁️ Deploy to Azure Web App
runs-on: ubuntu-latest
needs: Build-Docker-Image
name: Deploy app container to Azure
needs: docker_build

steps:
- name: "Login via Azure CLI"
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/docker-login@v1
- name: Azure Docker Login
uses: azure/docker-login@v1
with:
login-server: ${{env.IMAGE_REGISTRY_URL}}
login-server: ${{ env.IMAGE_REGISTRY_URL }}
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}

- name: Deploy web app container
- name: Deploy to Web App
uses: azure/webapps-deploy@v3
with:
app-name: ${{env.AZURE_WEBAPP_NAME}}
images: ${{env.IMAGE_REGISTRY_URL}}/${{ github.repository }}/${{env.DOCKER_IMAGE_NAME}}:${{github.sha}}
app-name: ${{ env.AZURE_WEBAPP_NAME }}
images: ${{ env.IMAGE_REGISTRY_URL }}/${{ github.repository }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }}

- name: Azure logout via Azure CLI
- name: Azure Logout
uses: azure/CLI@v2
with:
inlineScript: |
az logout
az cache purge
az account clear

Check warning on line 108 in .github/workflows/deploy-prod.yml

View check run for this annotation

GitHub Advanced Security / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions


Loading