Skip to content

Commit

Permalink
Merge #4093 Pass image from smoke to deploy, restore build caching
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed May 21, 2024
2 parents 2dbac5e + 940f315 commit 703aeb6
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 66 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore cache for _build/tools
uses: actions/cache@v3
with:
path: _build/tools
key: build-tools-${{ hashFiles('build', 'build.ps1', 'build.cake') }}
- name: Restore cache for _build/cake
uses: actions/cache@v3
with:
path: _build/cake
key: build-cake-${{ hashFiles('build.cake') }}
- name: Restore cache for _build/lib/nuget
uses: actions/cache@v3
with:
path: |
_build/lib/nuget
~/.nuget/packages
key: nuget-oldref-modules-${{ hashFiles('**/packages.config') }}-${{ hashFiles('**/*.csproj') }}
- name: Build ckan.exe and netkan.exe
run: ./build --configuration=${{ inputs.configuration }}
- name: Upload repack artifact
Expand Down
38 changes: 29 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,27 +164,47 @@ jobs:
- test-release
- smoke-inflator
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
- name: Download repack artifact
uses: actions/download-artifact@v4
with:
name: Release-repack-unsigned
path: _build/repack/
- name: Generate inflator Docker image, publish to Hub, and restart AWS containers
- name: Download Inflator image artifact
uses: actions/download-artifact@v4
with:
name: inflator-image
path: /tmp

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Load Inflator image
run: docker load --input /tmp/inflator-image.tar
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push Inflator image to Docker Hub
uses: docker/build-push-action@v5
with:
file: Dockerfile.netkan
context: _build/repack/Release
tags: kspckan/inflator:latest
push: true
- name: Redeploy Inflator containers
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_PASSWORD }}
shell: bash
run: |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
./build docker-inflator --configuration=Release --exclusive
docker image pull kspckan/netkan
for CONTAINER in InflatorKsp InflatorKsp2
do
docker run kspckan/netkan redeploy-service --cluster NetKANCluster --service-name $CONTAINER
done
upload-metadata-tester:
needs:
Expand Down
33 changes: 25 additions & 8 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,31 @@ jobs:
with:
name: Release-repack-unsigned
path: _build/repack/
- name: Run inflator container smoke test
working-directory: _build
run: |
cp -v repack/Release/netkan.exe .
docker build --tag inflator --file ../Dockerfile.netkan .
docker run --rm --name inflator --entrypoint /bin/bash inflator -c "
mono netkan.exe https://raw.githubusercontent.com/KSP-CKAN/NetKAN/master/NetKAN/ZeroMiniAVC.netkan
"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Inflator image
uses: docker/build-push-action@v5
with:
file: Dockerfile.netkan
context: _build/repack/Release
tags: kspckan/inflator
outputs: type=image
- name: Smoke test Inflator image
run: >
docker run --rm --entrypoint /bin/bash kspckan/inflator -c "mono netkan.exe
https://raw.githubusercontent.com/KSP-CKAN/NetKAN/master/NetKAN/ZeroMiniAVC.netkan"
- name: Export Inflator image tar file
uses: docker/build-push-action@v5
with:
file: Dockerfile.netkan
context: _build/repack/Release
tags: kspckan/inflator
outputs: type=docker,dest=/tmp/inflator-image.tar
- name: Upload Inflator image tar file artifact
uses: actions/upload-artifact@v4
with:
name: inflator-image
path: /tmp/inflator-image.tar
notify:
needs:
- build-release
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ All notable changes to this project will be documented in this file.
- [Multiple] Build nuget package, support netstandard2.0 build (#4039 by: HebaruSan)
- [Core] Use fully sanitized archive.org bucket names (#4043 by: HebaruSan)
- [Netkan] Omit duplicate inflation warnings in queue (#4071 by: HebaruSan)
- [Build] Refactor + Modernise Actions (#4082, #4088, #4089, #4091 by: techman83, HebaruSan; reviewed: HebaruSan)
- [Build] Refactor + Modernise Actions (#4082, #4088, #4089, #4091, #4093 by: techman83, HebaruSan; reviewed: HebaruSan)

## v1.34.4 (Niven)

Expand Down
48 changes: 0 additions & 48 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -49,54 +49,6 @@ Task("Netkan")
.Description("Build only netkan.exe")
.IsDependentOn("Repack-Netkan");

Task("docker-inflator")
.Description("Build the Docker image for the Inflator and push it to Dockerhub.")
.IsDependentOn("Repack-Netkan")
.Does(() =>
{
var dockerDirectory = buildDirectory.Combine("docker");
var inflatorDirectory = dockerDirectory.Combine("inflator");
// Versions of Docker prior to 18.03.0-ce require the Dockerfile to be within the build context
var dockerFile = inflatorDirectory.CombineWithFilePath("Dockerfile.netkan");
CreateDirectory(inflatorDirectory);
CopyFile(netkanFile, inflatorDirectory.CombineWithFilePath("netkan.exe"));
CopyFile(rootDirectory.CombineWithFilePath("Dockerfile.netkan"), dockerFile);
var mainTag = "kspckan/inflator";
var latestTag = mainTag + ":latest";
DockerBuild(
new DockerImageBuildSettings()
{
File = dockerFile.FullPath,
Tag = new string[] { mainTag }
},
inflatorDirectory.FullPath
);
DockerTag(mainTag, latestTag);
DockerPush(latestTag);
// Restart the Inflator
var netkanImage = "kspckan/netkan";
DockerPull(netkanImage);
var runSettings = new DockerContainerRunSettings()
{
Env = new string[]
{
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_DEFAULT_REGION"
}
};
DockerRun(runSettings, netkanImage,
"redeploy-service",
"--cluster", "NetKANCluster",
"--service-name", "InflatorKsp");
DockerRun(runSettings, netkanImage,
"redeploy-service",
"--cluster", "NetKANCluster",
"--service-name", "InflatorKsp2");
});

Task("docker-metadata")
.Description("Build the Docker image for the metadata testing and push it to Dockerhub.")
.IsDependentOn("Repack-Netkan")
Expand Down

0 comments on commit 703aeb6

Please sign in to comment.