Merge branch 'main' into yaml-fixes

This commit is contained in:
Matthew Alan Gray 2022-11-10 08:29:34 -06:00 коммит произвёл GitHub
Родитель e81be6a128 966c748623
Коммит 3a9a668513
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 143 добавлений и 69 удалений

Просмотреть файл

@ -440,71 +440,73 @@ Refer to the [Before the hands-on lab setup guide](Before%20the%20Hands-On%20Lab
- manifests/**
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
ACR_LOGIN_SERVER: <replace with your ACR name>.azurecr.io
AKS_NAMESPACE: health-check
CONTAINER_IMAGE: <replace with your ACR name>.azurecr.io/humongous-healthcare-api:${{ github.sha }}
steps:
- uses: actions/checkout@master
build-and-deploy:
runs-on: ubuntu-latest
env:
ACR_LOGIN_SERVER: <replace with your ACR name>.azurecr.io
AKS_NAMESPACE: health-check
CONTAINER_IMAGE: <replace with your ACR name>.azurecr.io/humongous-healthcare-api:${{ github.sha }}
steps:
- uses: actions/checkout@master
- uses: azure/docker-login@v1
with:
login-server: ${{ env.ACR_LOGIN_SERVER }}
username: ${{ secrets.acr_username }}
password: ${{ secrets.acr_password }}
- uses: azure/docker-login@v1
with:
login-server: ${{ env.ACR_LOGIN_SERVER }}
username: ${{ secrets.acr_username }}
password: ${{ secrets.acr_password }}
- name: Build and push image to ACR
id: build-image
run: |
docker build "$GITHUB_WORKSPACE/Humongous.Healthcare" -f "Humongous.Healthcare/Dockerfile" -t ${CONTAINER_IMAGE} --label dockerfile-path=Humongous.Healthcare/Dockerfile
docker push ${CONTAINER_IMAGE}
- name: Build and push image to ACR
id: build-image
run: |
docker build "$GITHUB_WORKSPACE/Humongous.Healthcare" -f "Humongous.Healthcare/Dockerfile" -t ${CONTAINER_IMAGE} --label dockerfile-path=Humongous.Healthcare/Dockerfile
docker push ${CONTAINER_IMAGE}
- uses: azure/k8s-set-context@v1
id: login
with:
kubeconfig: ${{ secrets.aks_kubeConfig }}
- uses: azure/k8s-set-context@v1
id: login
with:
kubeconfig: ${{ secrets.aks_kubeConfig }}
- name: Create namespace
run: |
namespacePresent=`kubectl get namespace | grep ${AKS_NAMESPACE} | wc -l`
if [ $namespacePresent -eq 0 ]
then
echo `kubectl create namespace ${AKS_NAMESPACE}`
fi
- name: Create namespace
run: |
namespacePresent=`kubectl get namespace | grep ${AKS_NAMESPACE} | wc -l`
if [ $namespacePresent -eq 0 ]
then
echo `kubectl create namespace ${AKS_NAMESPACE}`
fi
- uses: azure/k8s-create-secret@v1
name: dockerauth - create secret
with:
namespace: ${{ env.AKS_NAMESPACE }}
container-registry-url: ${{ env.ACR_LOGIN_SERVER }}
container-registry-username: ${{ secrets.acr_username }}
container-registry-password: ${{ secrets.acr_password }}
secret-name: dockerauth
- uses: azure/k8s-create-secret@v1
name: dockerauth - create secret
with:
namespace: ${{ env.AKS_NAMESPACE }}
container-registry-url: ${{ env.ACR_LOGIN_SERVER }}
container-registry-username: ${{ secrets.acr_username }}
container-registry-password: ${{ secrets.acr_password }}
secret-name: dockerauth
- uses: Azure/k8s-create-secret@v1
name: cosmosdb - create secret
with:
namespace: ${{ env.AKS_NAMESPACE }}
secret-type: 'generic'
secret-name: cosmosdb
arguments:
--from-literal=cosmosdb-account=${{ secrets.COSMOSDB_ACCOUNT }}
--from-literal=cosmosdb-key=${{ secrets.COSMOSDB_KEY }}
- uses: Azure/k8s-create-secret@v1
name: cosmosdb - create secret
with:
namespace: ${{ env.AKS_NAMESPACE }}
secret-type: 'generic'
secret-name: cosmosdb
arguments:
--from-literal=cosmosdb-account=${{ secrets.COSMOSDB_ACCOUNT }}
--from-literal=cosmosdb-key=${{ secrets.COSMOSDB_KEY }}
- uses: azure/k8s-deploy@v1.2
with:
namespace: ${{ env.AKS_NAMESPACE }}
manifests: |
manifests/deployment.yml
manifests/service.yml
images: |
${{ env.CONTAINER_IMAGE }}
imagepullsecrets: |
dockerauth
- uses: azure/k8s-deploy@v1.2
with:
namespace: ${{ env.AKS_NAMESPACE }}
manifests: |
manifests/deployment.yml
manifests/service.yml
images: |
${{ env.CONTAINER_IMAGE }}
imagepullsecrets: |
dockerauth
```
> Note: An example of this YAML file can be located in the `./actions` folder of this lab as `deployToAksCluster.yml`.
3. The workflow will fail on the intial run because it requires some secrets to be setup in the repository. Navigate to the repository in GitHub then select "Settings > Secrets > Actions". Finally use the "New Repository Secret" button to create secrets.
![Create a new repository secret.](media/github-new-repository-secret.png "New Repository Secret")
@ -640,14 +642,14 @@ Because this project uses the `Swashbuckle.AspNetCore` NuGet package, we can bui
REACT_APP_API_URL: ${{ secrets.API_URL }} # <<-- referencing the GitHub secrets
REACT_APP_API_KEY: ${{ secrets.API_KEY }} # <<-- created in Step 2
jobs:
build:
runs-on: windows-latest
build:
runs-on: windows-latest
defaults: # <<-- Add default working directory
run: # <<-- here to ensure deployment
working-directory: ./Humongous.Healthcare.Web/ # <<-- targets correct path.
defaults: # <<-- Add default working directory
run: # <<-- here to ensure deployment
working-directory: ./Humongous.Healthcare.Web/ # <<-- targets correct path.
steps:
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core

Просмотреть файл

@ -32,6 +32,24 @@ export class AddHealthCheck extends Component {
console.log("Test");
this.createHealthCheck();
}
handleAddSymptom = () => {
this.setState({ symptoms: [...this.state.symptoms, ""] });
}
handleSymptomInput = (index, event) => {
const symptoms = [...this.state.symptoms];
symptoms[index] = event.target.value;
this.setState({ symptoms });
}
handleDeleteSymptom = (index) => {
return () => {
const symptoms = this.state.symptoms;
symptoms.splice(index, 1);
this.setState({ symptoms });
}
}
render() {
return (
@ -39,9 +57,50 @@ export class AddHealthCheck extends Component {
<h4>Submit a HealthCheck:</h4>
<form onSubmit={this.handleSubmit}>
<input type="hidden" name="id" placeholder="Id" value="id" />
<input type="text" name="patientid" placeholder="Patient Id" value={this.state.patientid} onChange={this.handleInput} />
<input type="text" name="date" placeholder="Date" value={this.state.date} onChange={this.handleInput} />
<input type="text" name="healthstatus" placeholder="Health Status" value={this.state.healthstatus} onChange={this.handleInput} />
<div>
<label>
Patient ID:
<input type="text" name="patientid" placeholder="Patient Id" value={this.state.patientid} onChange={this.handleInput} />
</label>
</div>
<div>
<label>
Date:
<input type="date" name="date" placeholder="Date" value={this.state.date} onChange={this.handleInput} />
</label>
</div>
<div>
<label>
Health Status:
<input type="text" name="healthstatus" placeholder="Health Status" onChange={this.handleInput} />
</label>
</div>
<div>
<table className='table table-striped' aria-labelledby="tabelLabel">
<thead>
<tr>
<th>Symptom</th>
</tr>
</thead>
<tbody>
{this.state.symptoms.map((symptom, index) =>
<tr key={index}>
<td>
<input type="text" name="symptom" placeholder="Symptom" value={symptom || ""} onChange={e => this.handleSymptomInput(index, e)} />
</td>
<td><button className="button delete" type="button" onClick={this.handleDeleteSymptom(index)}>Delete</button></td>
</tr>
)}
</tbody>
<tfoot>
<tr>
<td>
<button className="button add" type="button" onClick={this.handleAddSymptom}>Add Symptom</button>
</td>
</tr>
</tfoot>
</table>
</div>
<button type="submit">Submit</button>
</form>
</div>

Просмотреть файл

@ -25,7 +25,7 @@ export class HealthCheck extends Component {
<td>{this.state.healthstatus}</td>
<td>
<ul>
{this.state.symptoms.map(symptom, index =>
{this.state.symptoms.map((symptom, index) =>
<li key={index}>{symptom}</li>
)}
</ul>

Просмотреть файл

@ -14,7 +14,9 @@
"applicationUrl": "https://localhost:7258;http://localhost:5271",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy",
"REACT_APP_API_URL": "https://localhost:5001/HealthCheck",
"REACT_APP_API_KEY": "SECRETKEY"
}
},
"IIS Express": {

Просмотреть файл

@ -22,7 +22,7 @@
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"applicationUrl": "http://localhost:5000;https://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

Просмотреть файл

@ -33,6 +33,15 @@ namespace Humongous.Healthcare
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Humongous.Healthcare", Version = "v1" });
});
services.AddSingleton<ICosmosDbService>(InitializeCosmosClientInstanceAsync(Configuration.GetSection("CosmosDb")).GetAwaiter().GetResult());
services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -47,6 +56,8 @@ namespace Humongous.Healthcare
app.UseRouting();
app.UseCors();
app.UseAuthorization();
app.UseEndpoints(endpoints =>

Просмотреть файл

@ -71,4 +71,4 @@ jobs:
images: |
${{ env.CONTAINER_IMAGE }}
imagepullsecrets: |
dockerauth
dockerauth