Skip to content

Commit d701564

Browse files
committed
Changed some path stuff for deployment
1 parent 51b14f0 commit d701564

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

.github/workflows/update-conf-2024-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
ARM_SUBSCRIPTION_ID: ${{ secrets.arm_subscription_id }}
4040
ARTIFACT_DOWNLOAD_PATH: ${{ github.workspace }}/release_artifacts
4141
ROOT_DIRECTORY_PATH: ${{ github.workspace }}/update-conference-prague-2024/demo-code-feedback-system/
42-
PULUMI_PATH: ${{ github.workspace }}/update-conference-prague-2024/demo-code-feedback-system/infra
42+
PULUMI_PATH: ${{ github.workspace }}/update-conference-prague-2024/demo-code-feedback-system/infra/pulumi-infra-deploy
4343
PULUMI_ACCESS_TOKEN: ${{ secrets.pulumi_access_token }}
4444
PULUMI_PROJECT_FILE_PATH: ${{ github.workspace }}/update-conference-prague-2024/demo-code-feedback-system/infra/PulumiInfra.csproj
4545

@@ -79,4 +79,4 @@ jobs:
7979
uses: pulumi/setup-pulumi@v2
8080

8181
- name: Cake Frosting - Deploy
82-
run: dotnet run --project ${{ env.ROOT_DIRECTORY_PATH }}/deploy/deploy/Deploy.csproj -- --configuration=${{ env.CONFIGURATION }} --PulumiStackName=${{ inputs.pulumi_stack_name }} --ReleaseVersion=${{ inputs.release_tag_id }} --WorkspacePath=${{ github.workspace }}
82+
run: dotnet run --project ${{ env.ROOT_DIRECTORY_PATH }}/deploy/deploy/Deploy.csproj -- --configuration=${{ env.CONFIGURATION }} --PulumiStackName=${{ inputs.pulumi_stack_name }} --ReleaseVersion=${{ inputs.release_tag_id }} --WorkspacePath=${{ github.workspace }} --ReleaseArtifactsDownloadDir=${{ github.ARTIFACT_DOWNLOAD_PATH }} --PulumiPath=${{ env.PULUMI_PATH }}

update-conference-prague-2024/demo-code-feedback-system/deploy/deploy/Program.cs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public class BuildContext : FrostingContext
2525
public string PulumiPath { get; }
2626
public string PulumiStackName { get; }
2727
public string ReleaseVersion { get; }
28-
public string UnzippedArtifactsDir { get; }
2928
public string ReleaseArtifactsDownloadDir { get; }
29+
public string UnzippedArtifactsDir { get; }
3030

3131
public BuildContext(ICakeContext context)
3232
: base(context)
@@ -35,9 +35,9 @@ public BuildContext(ICakeContext context)
3535
PulumiStackName = LoadParameter(context, nameof(PulumiStackName));
3636
ReleaseVersion = LoadParameter(context, nameof(ReleaseVersion));
3737

38-
PulumiPath = WorkspacePath + "/infra/pulumi-infra-deploy";
38+
PulumiPath = LoadParameter(context, nameof(PulumiPath));
39+
ReleaseArtifactsDownloadDir = LoadParameter(context, nameof(ReleaseArtifactsDownloadDir));
3940
UnzippedArtifactsDir = WorkspacePath + "/unzipped_artifacts";
40-
ReleaseArtifactsDownloadDir = WorkspacePath + "/release_artifacts";
4141
}
4242

4343
private string LoadParameter(ICakeContext context, string parameterName)
@@ -46,6 +46,39 @@ private string LoadParameter(ICakeContext context, string parameterName)
4646
}
4747
}
4848

49+
[TaskName(nameof(UnzipAssetsTask))]
50+
public sealed class UnzipAssetsTask : FrostingTask<BuildContext>
51+
{
52+
public override void Run(BuildContext context)
53+
{
54+
_ = Directory.CreateDirectory(context.UnzippedArtifactsDir);
55+
56+
ExtractArchive("feedback-web-client", context);
57+
}
58+
59+
private void ExtractArchive(string zipName, BuildContext context)
60+
{
61+
var zipFilePath = $"{context.ReleaseArtifactsDownloadDir}/{zipName}.zip";
62+
var outputPath = $"{context.UnzippedArtifactsDir}/{zipName}";
63+
64+
context.Log.Information($"Extracting zip '{zipFilePath}' to '{outputPath}'");
65+
66+
using var fileStream = File.OpenRead(zipFilePath);
67+
using var archive = new ZipArchive(fileStream);
68+
archive.ExtractToDirectory(outputPath);
69+
}
70+
71+
private void CopyArchive(string zipName, BuildContext context)
72+
{
73+
var zipFilePath = $"{context.ReleaseArtifactsDownloadDir}/{zipName}.zip";
74+
var outputPath = $"{context.UnzippedArtifactsDir}/{zipName}.zip";
75+
76+
context.Log.Information($"Copying zip '{zipFilePath}' to '{outputPath}'");
77+
File.Copy(sourceFileName: zipFilePath, destFileName: outputPath);
78+
}
79+
}
80+
81+
[IsDependentOn(typeof(UnzipAssetsTask))]
4982
[TaskName(nameof(UpdatePulumiConfigTask))]
5083
public sealed class UpdatePulumiConfigTask : FrostingTask<BuildContext>
5184
{
@@ -54,8 +87,8 @@ public override void Run(BuildContext context)
5487
var configFilePath = $"{context.PulumiPath}/Pulumi.{context.PulumiStackName}.yaml";
5588
var configFileText = File.ReadAllText(configFilePath);
5689

57-
configFileText = UpdateConfigValue("update-conf-2024:unzipped-artifacts-dir: ", context.UnzippedArtifactsDir, configFileText);
58-
configFileText = UpdateConfigValue("update-conf-2024:root-run-path: ", context.WorkspacePath, configFileText);
90+
configFileText = UpdateConfigValue("update-conf-2024:functions-package-path: ", $"{context.ReleaseArtifactsDownloadDir}/feedback-functions.zip", configFileText);
91+
configFileText = UpdateConfigValue("update-conf-2024:static-site-path: ", $"{context.UnzippedArtifactsDir}/feedback-web-client", configFileText);
5992

6093
File.WriteAllText(configFilePath, configFileText);
6194
context.Log.Information("Pulumi Config: \n" + configFileText);

0 commit comments

Comments
 (0)