Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass image from smoke to deploy, restore build caching #4093

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading