Static Web App은 HTML, CSS, JS와 같은 정적 파일로 구성된 웹 애플리케이션을 배포하는데 사용되는 구조나 서비스를 말한다. 여기에는 주로 CSR을 통해 실행되는 SPA 또는 정적 웹사이트가 포함된다.
대표적인 Static Web App 호스팅 서비스로는 Netlify, Vercel, Github Pages, Azure Static Web Apps 등이 있다.
이 중 Azure Static Web App은 CI/CD를 지원한다.
Azure Static Web App을 CI/CD와 연계하면 코드를 변경하는 즉시 자동으로 빌드, 테스트, 배포가 진행된다. 이를 통해 빠른 개발과 안정적인 배포가 가능하며, Git 기반 워크플로우를 중심으로 효율적인 작업을 지원한다.
Azure Static Web App은 GitHub, Azure DevOps와 같은 Git 기반 소스 컨트롤과 통합되어 CI/CD 파이프라인을 자동화한다.
Azure Static Web App은 리소스를 생성할 때 자동으로 GitHub Actions workflow를 설정한다. 생성된 *.yml 파일은 다음과 같은 과정으로 진행된다.
1. 빌드 및 배포 트리거
// 예시
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Action
uses: actions/checkout@v2
- name: Build And Deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
app_location: "/"
api_location: "api"
output_location: "build"
AZURE_STATIC_WEB_APPS_API_TOKEN이나 GITHUB_TOKEN을 설정해야 Azure와 CI/CD가 통신할 수 있다. deploy:
needs: lint_and_test
runs-on: ubuntu-latest
name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to Azure Static Web Apps
id: deploy
uses: Azure/static-web-apps-deploy@latest
with: //#1. API Key 설정
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WITTY_HILL_0EE86E600 }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
app_location: '/'
api_location: ''
output_location: 'out' //#2. 빌드 출력 경로
env:
~~