diff --git a/.github/workflows/build_aws_scheduled.yml b/.github/workflows/build_aws_scheduled.yml index 414e02a..c24abdf 100644 --- a/.github/workflows/build_aws_scheduled.yml +++ b/.github/workflows/build_aws_scheduled.yml @@ -102,3 +102,64 @@ jobs: PKR_VAR_ami_name_prefix: spacelift-${{ needs.timestamp.outputs.timestamp }} PKR_VAR_source_ami_architecture: ${{ matrix.arch }} PKR_VAR_instance_type: ${{ matrix.arch == 'x86_64' && 't3.micro' || 't4g.micro' }} + + print-markdown: + needs: [build] + name: Print the AMI IDs in a markdown format + runs-on: ubuntu-latest + steps: + - name: Download x64 manifest + uses: actions/download-artifact@v3 + with: + name: manifest_aws_x86_64.json + path: manifest_aws_x86_64.json + + - name: Download arm64 manifest + uses: actions/download-artifact@v3 + with: + name: manifest_aws_arm64.json + path: manifest_aws_arm64.json + + # The manifest file look like this: + # "builds": [ + # { + # "name": "spacelift", + # "builder_type": "amazon-ebs", + # "build_time": 1698670371, + # "files": null, + # "artifact_id": "ap-northeast-1:ami-0facbd2b91807c339,ap-northeast-2:ami-03849b8d23619dfb2,... + # } + # ] + + - name: Print in a markdown format + uses: actions/github-script@v6 + with: + script: | + const fs = require("fs"); + + var content = fs.readFileSync("./manifest_aws_arm64.json", "utf8"); + var manifest = JSON.parse(content); + + const toPrint = []; + manifest["builds"].forEach((build) => { + const regionToAmi = build["artifact_id"].split(","); + regionToAmi.forEach((regionToAmi) => { + const [region, ami] = regionToAmi.split(":"); + toPrint.push(`| ${region} | ${ami} |`); + }); + }); + + content = fs.readFileSync("./manifest_aws_x86_64.json", "utf8"); + manifest = JSON.parse(content); + + manifest["builds"].forEach((build) => { + const regionToAmi = build["artifact_id"].split(","); + regionToAmi.forEach((regionToAmi, i) => { + const [region, ami] = regionToAmi.split(":"); + toPrint[i] = toPrint[i] + ` ${ami} |`; + }); + }); + + console.log("| AWS Region | AMI ID (ARM64) | AMI ID (x86_64) |"); + console.log("|------------------|-------------------------|-------------------------|"); + toPrint.forEach(line => console.log(line)); diff --git a/.github/workflows/build_gcp_azure_manual.yml b/.github/workflows/build_gcp_azure_manual.yml index c57ad22..8492eb1 100644 --- a/.github/workflows/build_gcp_azure_manual.yml +++ b/.github/workflows/build_gcp_azure_manual.yml @@ -109,3 +109,51 @@ jobs: path: manifest_${{ matrix.cloud }}.json name: manifest_${{ matrix.cloud }}.json retention-days: 5 + + print-markdown: + needs: [build] + name: Print the AMI IDs in a markdown format + runs-on: ubuntu-latest + steps: + - name: Download Azure manifest + uses: actions/download-artifact@v3 + with: + name: manifest_azure.json + path: manifest_azure.json + + - name: Download Google Cloud manifest + uses: actions/download-artifact@v3 + with: + name: manifest_gcp.json + path: manifest_gcp.json + + # Enable this once we know the final format + - name: Print in a markdown format + if: false + uses: actions/github-script@v6 + with: + script: | + import { readFileSync } from 'fs'; + + var content = readFileSync("./manifest_azure.json", "utf8"); + var manifest = JSON.parse(content); + + const azureVersion = manifest["builds"][0]["artifact_id"].split(":")[1]; + + content = readFileSync("./manifest_gcp.json", "utf8"); + manifest = JSON.parse(content); + + const gcpVersion = manifest["builds"][0]["artifact_id"].split(":")[1]; + + console.log("## Azure"); + console.log(""); + console.log(`- Publisher | \`spaceliftinc1625499025476\`.`); + console.log(`- Offer | \`spacelift_worker\`.`); + console.log(`- SKU | \`ubuntu_20_04\`.`); + console.log(`- Version | \`${azureVersion}\`.`); + console.log(""); + console.log("## Google Cloud Platform"); + console.log(""); + console.log(`- United States | \`spacelift-worker-us-1698150055-${gcpVersion}\``); + console.log(`- Europe | \`spacelift-worker-eu-1698150055-${gcpVersion}\``); + console.log(`- Asia | \`spacelift-worker-asia-1698150055-${gcpVersion}\``); \ No newline at end of file