ノート: GitHubホストランナーは、現在GitHub Enterprise Serverでサポートされていません。 GitHubパブリックロードマップで、計画されている将来のサポートに関する詳しい情� �を見ることができます。
はじめに
This guide explains how to use GitHub Actions to build and deploy a web app to Azure Static Web Apps.
必要な環境
GitHub Actionsワークフローを作成する前に、まず以下のセットアップのステップを完了しておかなければなりません。
-
Create an Azure Static Web App using the 'Other' option for deployment source. For more information, see "Quickstart: Building your first static site in the Azure portal" in the Azure documentation.
-
Create a secret called
AZURE_STATIC_WEB_APPS_API_TOKENwith the value of your static web app deployment token. For more information about how to find your deployment token, see "Reset deployment tokens in Azure Static Web Apps" in the Azure documentation.
ワークフローの作成
必要な環境を整えたら、ワークフローの作成に進むことができます。
The following example workflow demonstrates how to build and deploy an Azure static web app when there is a push to the main branch or when a pull request targeting main is opened, synchronized, or reopened. The workflow also tears down the corresponding pre-production deployment when a pull request targeting main is closed.
Under the workflow env key, change the following values:
APP_LOCATIONto the location of your client codeAPI_LOCATIONto the location of your API source code. IfAPI_LOCATIONis not relevant, you can delete the variable and the lines where it is used.APP_ARTIFACT_LOCATIONto the location of your client code build output
For more information about these values, see "Build configuration for Azure Static Web Apps" in the Azure documentation.
# このワークフローはGitHubによって認定されていないアクションを使用します。 # それらはサードパーティによって提供され、 # 別個の利用規約、プライバシーポリシー、 # サポートドキュメンテーションが適用されます。 name: Deploy web app to Azure Static Web Apps env: APP_LOCATION: "/" # location of your client code API_LOCATION: "api" # location of your api source code - optional APP_ARTIFACT_LOCATION: "build" # location of client code build output on: push: branches: - main pull_request: types: [opened, synchronize, reopened, closed] branches: - main permissions: issues: write jobs: build_and_deploy: if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') runs-on: ubuntu-latest name: Build and Deploy steps: - uses: actions/checkout@v2 with: submodules: true - name: Build And Deploy uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9 with: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }} action: "upload" app_location: ${{ env.APP_LOCATION }} api_location: ${{ env.API_LOCATION }} app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }} close: if: github.event_name == 'pull_request' && github.event.action == 'closed' runs-on: ubuntu-latest name: Close steps: - name: Close uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9 with: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} action: "close"追� リソース
以下のリソースも役に立つでしょう。
- オリジナルのスターターワークフローについては、GitHub Actions
starter-workflowsリポジトリ中のazure-staticwebapp.ymlを参照してく� さい。 - The action used to deploy the web app is the official Azure
Azure/static-web-apps-deployaction. - For more examples of GitHub Action workflows that deploy to Azure, see the actions-workflow-samples repository.