Action input kubernetes->kubernetesBase64Config

pull/123/head
Frostebite 2020-07-14 02:52:08 +01:00
parent 3ec01bf2a4
commit e76aa4f710
7 changed files with 19 additions and 9 deletions

View File

@ -104,13 +104,17 @@ jobs:
--zone $GKE_ZONE --project $GKE_PROJECT --zone $GKE_ZONE --project $GKE_PROJECT
# run a command to get access-token # run a command to get access-token
kubectl version kubectl version
- uses: frostebite/File-To-Base64@master
id: read-k8-config
with:
filePath: ~/.kube/config
- uses: ./ - uses: ./
id: k8-unity-build id: k8-unity-build
env: env:
UNITY_LICENSE: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <License id=\"Terms\">\n <MachineBindings>\n <Binding Key=\"1\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n <Binding Key=\"2\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n </MachineBindings>\n <MachineID Value=\"xWka2iXdDJejhZdi/zU2RUeXUi4=\"/>\n <SerialHash Value=\"1efd68fa935192b6090ac03c77d289a9f588c55a\"/>\n <Features>\n <Feature Value=\"33\"/>\n <Feature Value=\"1\"/>\n <Feature Value=\"12\"/>\n <Feature Value=\"2\"/>\n <Feature Value=\"24\"/>\n <Feature Value=\"3\"/>\n <Feature Value=\"36\"/>\n <Feature Value=\"17\"/>\n <Feature Value=\"19\"/>\n <Feature Value=\"62\"/>\n </Features>\n <DeveloperData Value=\"AQAAAEY0LUg2WFMtUE00NS1SM0M4LUUyWlotWkdWOA==\"/>\n <SerialMasked Value=\"F4-H6XS-PM45-R3C8-E2ZZ-XXXX\"/>\n <StartDate Value=\"2018-05-02T00:00:00\"/>\n <UpdateDate Value=\"2020-06-14T13:49:47\"/>\n <InitialActivationDate Value=\"2018-05-02T14:21:28\"/>\n <LicenseVersion Value=\"6.x\"/>\n <ClientProvidedVersion Value=\"2019.3.15f1\"/>\n <AlwaysOnline Value=\"false\"/>\n <Entitlements>\n <Entitlement Ns=\"unity_editor\" Tag=\"UnityPersonal\" Type=\"EDITOR\" ValidTo=\"9999-12-31T00:00:00\"/>\n </Entitlements>\n </License>\n<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#Terms\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>bpzWx3PZ0lqWDo1m9aLQuZ4cweo=</DigestValue></Reference></SignedInfo><SignatureValue>QcDm4/qAXZuUMQbUVk63vO6u66Bp8PnqqWQcZZOcym/rGUZLj1sr66EquF3X3w1L7aqiwMGtbY2b\nkPttcalFeaBkc5NsJMrexWjuBCxQvhbmVFQnTjvC6vNS+k1wrkz7If1oPkz/XaDtCfUs8oxc9iPe\nPzzUJIVYLZoDtpPq2XbgVn9/TiVb3Zu6ldKgvtNRYUjrB3KywtvL9OcIFll3htRcBZPG43kxryJc\nDD2TL5Nw1JuX6MejBBuYTZsZNpGX9Pjop9+uFUZ4GI9h8a5g6wJUfXzsGw7j4gkvDkC9MvyWiksi\n2hNXw1QNeB6JfQsd4sAuhYh/CqTm2gCz9i9ZpA==</SignatureValue></Signature></root>" UNITY_LICENSE: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <License id=\"Terms\">\n <MachineBindings>\n <Binding Key=\"1\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n <Binding Key=\"2\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n </MachineBindings>\n <MachineID Value=\"xWka2iXdDJejhZdi/zU2RUeXUi4=\"/>\n <SerialHash Value=\"1efd68fa935192b6090ac03c77d289a9f588c55a\"/>\n <Features>\n <Feature Value=\"33\"/>\n <Feature Value=\"1\"/>\n <Feature Value=\"12\"/>\n <Feature Value=\"2\"/>\n <Feature Value=\"24\"/>\n <Feature Value=\"3\"/>\n <Feature Value=\"36\"/>\n <Feature Value=\"17\"/>\n <Feature Value=\"19\"/>\n <Feature Value=\"62\"/>\n </Features>\n <DeveloperData Value=\"AQAAAEY0LUg2WFMtUE00NS1SM0M4LUUyWlotWkdWOA==\"/>\n <SerialMasked Value=\"F4-H6XS-PM45-R3C8-E2ZZ-XXXX\"/>\n <StartDate Value=\"2018-05-02T00:00:00\"/>\n <UpdateDate Value=\"2020-06-14T13:49:47\"/>\n <InitialActivationDate Value=\"2018-05-02T14:21:28\"/>\n <LicenseVersion Value=\"6.x\"/>\n <ClientProvidedVersion Value=\"2019.3.15f1\"/>\n <AlwaysOnline Value=\"false\"/>\n <Entitlements>\n <Entitlement Ns=\"unity_editor\" Tag=\"UnityPersonal\" Type=\"EDITOR\" ValidTo=\"9999-12-31T00:00:00\"/>\n </Entitlements>\n </License>\n<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#Terms\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>bpzWx3PZ0lqWDo1m9aLQuZ4cweo=</DigestValue></Reference></SignedInfo><SignatureValue>QcDm4/qAXZuUMQbUVk63vO6u66Bp8PnqqWQcZZOcym/rGUZLj1sr66EquF3X3w1L7aqiwMGtbY2b\nkPttcalFeaBkc5NsJMrexWjuBCxQvhbmVFQnTjvC6vNS+k1wrkz7If1oPkz/XaDtCfUs8oxc9iPe\nPzzUJIVYLZoDtpPq2XbgVn9/TiVb3Zu6ldKgvtNRYUjrB3KywtvL9OcIFll3htRcBZPG43kxryJc\nDD2TL5Nw1JuX6MejBBuYTZsZNpGX9Pjop9+uFUZ4GI9h8a5g6wJUfXzsGw7j4gkvDkC9MvyWiksi\n2hNXw1QNeB6JfQsd4sAuhYh/CqTm2gCz9i9ZpA==</SignatureValue></Signature></root>"
with: with:
targetPlatform: ${{ matrix.targetPlatform }} targetPlatform: ${{ matrix.targetPlatform }}
kubernetes: true kubernetesBase64Config: ${{ steps.read-k8-config.outputs.base64 }}
githubToken: ${{ secrets.GITHUB_TOKEN }} githubToken: ${{ secrets.GITHUB_TOKEN }}
projectPath: test-project projectPath: test-project
unityVersion: 2019.3.15f1 unityVersion: 2019.3.15f1
@ -118,6 +122,7 @@ jobs:
cp $HOME/.kube/config ./kubeconfig cp $HOME/.kube/config ./kubeconfig
- uses: frostebite/kubernetes-download-pv@master - uses: frostebite/kubernetes-download-pv@master
with: with:
kubernetesBase64Config: ${{ steps.read-k8-config.outputs.base64 }}
pv: ${{ steps.k8-unity-build.outputs.volume }} pv: ${{ steps.k8-unity-build.outputs.volume }}
sourcePath: repo/build/ sourcePath: repo/build/
env: env:

View File

@ -26,10 +26,10 @@ inputs:
required: false required: false
default: '' default: ''
description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.' description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.'
kubernetes: kubernetesBase64Config:
default: '' default: ''
required: false required: false
description: 'Use kubernetes to clone the repo and run the build this will use kubernetes APPLICATION DEFAULT CREDENTIALS to access the current cluster context' description: 'Supply a base64 encoded kubernetes config to run builds on kubernetes and stream logs until completion.'
githubToken: githubToken:
default: '' default: ''
required: false required: false

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@ async function action() {
const buildParameters = await BuildParameters.create(); const buildParameters = await BuildParameters.create();
const baseImage = new ImageTag(buildParameters); const baseImage = new ImageTag(buildParameters);
if (buildParameters.kubernetes) { if (buildParameters.kubernetesBase64Config) {
core.info('Building with Kubernetes'); core.info('Building with Kubernetes');
await Kubernetes.runBuildJob(buildParameters, baseImage); await Kubernetes.runBuildJob(buildParameters, baseImage);
} else { } else {

View File

@ -36,7 +36,7 @@ class BuildParameters {
androidKeyaliasName: Input.androidKeyaliasName, androidKeyaliasName: Input.androidKeyaliasName,
androidKeyaliasPass: Input.androidKeyaliasPass, androidKeyaliasPass: Input.androidKeyaliasPass,
customParameters: Input.customParameters, customParameters: Input.customParameters,
kubernetes: Input.kubernetes, kubernetesBase64Config: Input.kubernetesBase64Config,
githubToken: Input.githubToken, githubToken: Input.githubToken,
}; };
} }

View File

@ -81,8 +81,8 @@ class Input {
return core.getInput('customParameters') || ''; return core.getInput('customParameters') || '';
} }
static get kubernetes() { static get kubernetesBase64Config() {
return core.getInput('kubernetes') || false; return core.getInput('kubernetesBase64Config') || false;
} }
static get githubToken() { static get githubToken() {

View File

@ -1,11 +1,16 @@
const KubeClient = require('kubernetes-client').Client; const KubeClient = require('kubernetes-client').Client;
const core = require('@actions/core'); const core = require('@actions/core');
const base64 = require('base-64'); const base64 = require('base-64');
const { KubeConfig } = require('kubernetes-client');
const Request = require('kubernetes-client/backends/request');
class Kubernetes { class Kubernetes {
static async runBuildJob(buildParameters, baseImage) { static async runBuildJob(buildParameters, baseImage) {
// uses default kubeconfig location/env variable // uses default kubeconfig location/env variable
const kubeClient = new KubeClient(); const kubeconfig = new KubeConfig();
kubeconfig.loadFromString(base64.decode(buildParameters.kubernetesBase64Config));
const backend = new Request({ kubeconfig });
const kubeClient = new KubeClient(backend);
await kubeClient.loadSpec(); await kubeClient.loadSpec();
const buildId = Kubernetes.uuidv4(); const buildId = Kubernetes.uuidv4();