A dependent branch is a branch of Timekeeper using own branding (colors, logos etc) and living in its own Static Web App instance, but using the common Storage, Azure Functions and Azure SignalR service instances.
If you are looking to deploy a completely independent version of Timekeeper (using its own instance of Storage, Azure Functions and Azure SignalR service), please check this page.
- Clone or fork this repo.
- If you already have this repo cloned or forked locally, make sure that you have the latest by either pulling from origin (local clone) or fetch upstream (local fork).
- Checkout the
main
branch. - Create a new branch. In this document we will refer to it as
your-new-branch
. - With the new branch checked out, open
Client\wwwroot\appsettings.json
. - Replace the GUID under
BranchId
with a new one. - Open
Client\wwwroot\appsettings.Development.json
. - Replace the GUID under
BranchId
with a new one. - Replace
Client\wwwroot\images\header-logo.png
with a new logo. - Open
Client\wwwroot\css\branch.css
. - Edit the CSS styles.
- Open
Client\Model\Branding.cs
. - Edit the properties.
If you want the branch to be protected by roles, you need to set it up as follows:
- In
Client\Model\Branding.cs
, setMustAuthorize
totrue
. - Open
Client\wwwroot\routes.json
. - Modify the json as follows:
{
"routes": [
{
"route": "/api/*",
"allowedRoles": [ "host" ]
},
{
"route": "/*",
"serve": "/index.html",
"statusCode": 200
}
]
}
If you want to verify your changes, you can run the new branch locally. Follow the steps described in Running the app locally.
Once you are satisfied with your changes, you can prepare the code for automated deployment into a new Azure Static Web App instance.
- Commit all your changes and push the new branch to the repo.
- Go to the Azure portal.
- Create a new Static Web App instance with the following settings:
- Create a new resource group.
- Enter the app name.
- Select the hosting plan you need.
- Select the region.
- Select
GitHub
underDeployment details
. - Click on
Sign in with GitHub
. - Authorize Azure Static Web Apps to access your GitHub account.
- After you are authorized, select the organization into which your repo is located.
- Select the repository.
- Select the branch you just pushed.
- Under
Build Presets
, selectBlazor
. - Leave
App location
,Api location
andOutput location
to the defaults. - Click
Review and create
. - Click
Create
. - Wait until the deployment is complete.
- Switch to the Timekeeper repo's actions.
- Wait until the action successfully completes.
- Navigate to the new Static Web App instance in the Azure portal.
- Open the Application Insights tab.
- Set
Enable Application Insights
toYes
. - Leave the other options as is.
- Click on
Save
.
- Set
- Open the Configuration tab.
- Set
AzureSignalRConnectionString
to the connection string for the Azure SignalR service instance. - Set
AzureStorage
to the connection string for the Storage account.
- Set
- Save the configuration.
To obtain the connection strings, contact [email protected].
- Configure the custom domain with your domain name provider.
- Add a CNAME record.
- Point the CNAME record to the Static Web App's domain.
- Go back to the Static web app instance.
- Click the Custom domain tab.
- Click
Add
. - Enter the custom domain you just configured.
- Click
Next
. - Click
Add
.
It can take a few minutes for the configuration to come through.
If you decided to protect your branch, follow the steps to configure the roles:
- Open the Role management tab.
- Invite the hosts as needed.
- Click on Invite.
- Select
GitHub
orTwitter
asAuthentication provider
. - Enter the new host's handle or username.
- Leave the domain as is.
- Set the
Role
tohost
. - Set the expiration time as needed.
- Click on
Generate
. - Copy the link and send to the new host so he can log in and register.
The last step is setting up CORS in the Azure Functions instance.
- Open the Overview tab.
- Copy the
URL
. - Open the Azure Functions application.
- Open the CORS tab.
- Add the URL you just copied.
- Save.
At this point the application should run fine.
Optionally you can change the following settings:
- Change the name of the GitHub action that was generated for your Static Web App instance to follow the conventions of the other actions.
- Change the name of the GitHub token used by this action.
- Go to the Azure Static Web App in the portal.
- Select
Manage deployment token
. - Copy the token.
- Go to GitHub action secrets
- Create a
New repository secret
namedSWA_TOKEN_[YOUR_BRANCH]
. - Paste the token you copied.
- Click
Add secret
. - Update the token name in the GitHub action (in 2 locations).
- Remove the old token from the secrets.