This repository provides continuous integration and deployment processes using GitHub workflow to create and maintain a Lighthouse CI solution hosted on Microsoft's Azure platform. This solution also provides a demo Web application so the Lighthouse would able to run the audits on it.
-
Demo Web Application (
./demo-app
): Web application that is used to run the Lighthouse audits on it. -
Lighthouse CI Client (
./lighthouse-ci/client
): Responsible for running the Lighthouse audits on the demo Web application. -
Lighthouse CI Server (
./lighthouse-ci/server
): Responsible for storing the Lighthouse audits reports, and providing a web interface for viewing the reports.
On every push to the main
branch, the GitHub Actions workflow will run the following steps:
- Deploy the demo Web application to a staging slot.
- Run the Lighthouse audits on the staging slot and store the reports in the Lighthouse CI Server.
- If the audits passed, swap the demo Web application's staging slot with the production slot.
graph TD
setup["Setup"]
deploy-lighthouse-db["Deploy Lighthouse DB"]
build-lighthouse-server["Build Lighthouse CI Server"]
deploy-lighthouse-server["Deploy Lighthouse CI Server"]
create-lighthouse-ci-project["Create Lighthouse CI Project"]
build-demo-app["Build Demo App"]
deploy-demo-app-staging["Deploy Demo App to Staging"]
build-lighthouse-client["Build Lighthouse Client"]
deploy-lighthouse-client["Deploy Lighthouse Client"]
swap-demo-app-production["Swap Demo App Production"]
setup --> deploy-lighthouse-db
setup --> build-lighthouse-server
setup --> build-demo-app
setup --> build-lighthouse-client
deploy-lighthouse-db --> deploy-lighthouse-server
build-lighthouse-server --> deploy-lighthouse-server
deploy-lighthouse-server --> create-lighthouse-ci-project
build-demo-app --> deploy-demo-app-staging
build-lighthouse-client --> deploy-lighthouse-client
create-lighthouse-ci-project --> deploy-lighthouse-client
deploy-demo-app-staging --> deploy-lighthouse-client
deploy-lighthouse-client --> swap-demo-app-production
-
Azure Resource Group: A logical container for grouping the Azure resources that are required to run this solution.
-
Azure Container Registry: Host the Docker images for the demo Web application and the Lighthouse CI Client & Server.
-
Azure Database for MySQL: The database for the Lighthouse CI Server.
-
Azure Container Apps: Host the demo Web application Lighthouse CI Server.
-
Azure Container Instance: Running the Lighthouse CI Client.
-
Azure Key Vault: Store the Lighthouse CI project tokens.
Fork this repository to your GitHub account by clicking the Fork button at the top of this page.
If you do not have an Azure subscription, create a new one:
- Log in to the Azure Portal.
- Navigate to the Subscriptions service.
- Click Add.
- Follow the steps to create a new subscription.
- Note down the subscription id for the
AZURE_SUBSCRIPTION_ID
GitHub secret later.
The AAD Application acts as an identity for the GitHub Actions workflow to interact with Azure services.
- Log in to the Azure Portal.
- Navigate to the App registrations service.
- Click New registration.
- Enter a name for the application, and then click Register.
- Once the application is created, note down the Application (client) ID (
AZURE_CLIENT_ID
) and Directory (tenant) ID (AZURE_TENANT_ID
) for the GitHub secrets later.
The GitHub Actions workflow needs to be able to authenticate with Azure using the AAD Application that you created earlier.
- Navigate to your AAD application that you created earlier.
- Navigate to the Certificates & secrets view.
- Navigate to the Federated credentials tab.
- Click Add credential.
- Select GitHub Actions deploying Azure resources as the Federated credential scenario.
- Enter your GitHub organization name and repository name.
- Select Branch as the Entity type and fill in main as the GitHub branch name.
- Generate a name for the federated credential.
- Click Add.
The AAD Application needs to be assigned as a Owner role on your Azure subscription so it can create and manage the Azure resources.
- Navigate to your Azure subscription.
- Select Access control (IAM), then click Add role assignment.
- In the Role pane, select Privileged administrator role and select Owner as the role
- Click Next or Members, select Assign access to to User, group, or service principal, and select the AAD application that you created earlier.
- Click Assign.
In your GitHub repository, go to Settings -> Secrets and variables -> Actions -> Variables -> New repository secret and add the following variables:
APP_NAME
: Generate an unique application name. Lowercase words separated by dashes. For example,my-app
.
In your GitHub repository, go to Settings -> Secrets and variables -> Actions -> New repository secret and add the following secrets:
AZURE_CLIENT_ID
: The Application (client) ID of the AAD application you created earlier.AZURE_TENANT_ID
: The Directory (tenant) ID of the AAD application.AZURE_SUBSCRIPTION_ID
: The Subscription ID of your Azure subscription.
Once everything is set up, you can now run the GitHub Actions workflow by pushing a commit to the main
branch.