Skip to content

Commit

Permalink
feat: add yaml generator for aws codepipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 21, 2023
1 parent e814451 commit 102ceef
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 69 deletions.
104 changes: 35 additions & 69 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions src/aws/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# AWS CodePipeline

[![deno module](https://shield.deno.dev/x/fly_pipeline)](https://deno.land/x/fly_pipeline)
![deno compatibility](https://shield.deno.dev/deno/^1.34)
[![](https://img.shields.io/codecov/c/gh/fluent-ci-templates/fly-pipeline)](https://codecov.io/gh/fluent-ci-templates/fly-pipeline)

The following command will generate a `buildspec.yml` file in your project:

```bash
fluentci ac init -t fly_pipeline
```

Generated file:

```yaml
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_aws_codepipeline

version: 0.2
phases:
install:
commands:
- curl -fsSL https://deno.land/x/install/install.sh | sh
- export DENO_INSTALL="$HOME/.deno"
- export PATH="$DENO_INSTALL/bin:$PATH"
- deno install -A -r https://cli.fluentci.io -n fluentci
- curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
- mv bin/dagger /usr/local/bin
- dagger version
build:
commands:
- dagger run fluentci fly_pipeline
post_build:
commands:
- echo Build completed on `date`
env:
secrets-manager:
FLY_API_TOKEN: fly:FLY_API_TOKEN

```

Feel free to edit the template generator at `.fluentci/src/aws/config.ts` to your needs.
29 changes: 29 additions & 0 deletions src/aws/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { BuildSpec } from "fluent_aws_codepipeline";

export function generateYaml(): BuildSpec {
const buildspec = new BuildSpec();
buildspec
.env({
"secrets-manager": {
FLY_API_TOKEN: "fly:FLY_API_TOKEN",
},
})
.phase("install", {
commands: [
"curl -fsSL https://deno.land/x/install/install.sh | sh",
'export DENO_INSTALL="$HOME/.deno"',
'export PATH="$DENO_INSTALL/bin:$PATH"',
"deno install -A -r https://cli.fluentci.io -n fluentci",
"curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh",
"mv bin/dagger /usr/local/bin",
"dagger version",
],
})
.phase("build", {
commands: ["dagger run fluentci fly_pipeline"],
})
.phase("post_build", {
commands: ["echo Build completed on `date`"],
});
return buildspec;
}
9 changes: 9 additions & 0 deletions src/aws/config_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
import { generateYaml } from "./config.ts";

Deno.test(function generateAWSCodePipelineTest() {
const buildspec = generateYaml();
const actual = buildspec.toString();
const expected = Deno.readTextFileSync("./fixtures/buildspec.yml");
assertEquals(actual, expected);
});
3 changes: 3 additions & 0 deletions src/aws/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { generateYaml } from "./config.ts";

generateYaml().save("buildspec.yml");

0 comments on commit 102ceef

Please sign in to comment.