Skip to content

Commit

Permalink
Print markdown at the end of AWS job
Browse files Browse the repository at this point in the history
Signed-off-by: peterdeme <[email protected]>
  • Loading branch information
peterdeme committed Oct 25, 2023
1 parent 3b51385 commit 68993e2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build_aws_scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,47 @@ 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

- name: Download arm64 manifest
uses: actions/download-artifact@v3
with:
name: manifest_aws_arm64.json

- name: Print in a markdown format
uses: actions/github-script@v6
with:
script: |
import { readFileSync } from 'fs';
var content = readFileSync("./manifest_aws_arm64.json", "utf8");
var manifest = JSON.parse(content);
const toPrint = [];
manifest["builds"].forEach((build) => {
const [region, ami] = build["artifact_id"].split(":");
toPrint.push(`| ${region} | ${ami} |`);
});
content = readFileSync("./manifest_aws_x86_64.json", "utf8");
manifest = JSON.parse(content);
manifest["builds"].forEach((build, i) => {
const [region, ami] = build["artifact_id"].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);
});

0 comments on commit 68993e2

Please sign in to comment.