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

feat: (RI-4198) Add onepassword provider #1

Merged
merged 15 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
54 changes: 54 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 📝 Lint

on:
pull_request:

concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: 💻 Checkout current code ref
uses: actions/checkout@v4

- name: 🟢 Configure Bun on runner
uses: oven-sh/setup-bun@v1

- name: 📦 Install package dependencies using lockfile
run: bun install --frozen-lockfile

- name: 🔨 Run build
run: bun run build

- name: 🌷 Run format, lint & check with Biome
run: |
bun run format
bun run lint
bun run check

commitlint:
runs-on: ubuntu-latest
steps:
- name: 💻 Checkout current code ref
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🟢 Configure Bun on runner
uses: oven-sh/setup-bun@v1

- name: 🚧 Install dev dependencies
run: npm install --only=dev

# Check all commits pushed to this PR
- name: 👁️‍🗨️ Validate PR commits with commitlint
run: >-
npx commitlint
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}
--to ${{ github.event.pull_request.head.sha }}
--verbose
- name: 🔎 Validate PR title with commitlint
run: echo "${{ github.event.pull_request.title }}" | npx commitlint
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 🚀 Release

on:
workflow_dispatch:

env:
NAME: 'dot-env-generator'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: 💻 Checkout current pull-request revision code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🟢 Configure Bun on runner
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: 🔵 Install Task
uses: arduino/setup-task@v2

- name: 💼 Configure Git user
run: |
git config user.name "gbh-devops-bot"
git config user.email "[email protected]"

- name: 📦 Install package dependencies using lockfile
run: bun install --frozen-lockfile

- name: 🔨 Run build
run: bun run build

- name: 🔨 Compile binary for supported platforms
run: task build-and-compress

- name: 🚀 Run new version for production
run: npx release-it --ci
env:
GITHUB_TOKEN: ${{ secrets.DEVOPS_USER_TOKEN }}
6 changes: 0 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,5 @@ jobs:
bun run build
bun run compile

- name: 🌷 Run format, lint & check with Biome
run: |
bun run format:ci
bun run lint:ci
bun run check:ci

- name: 🧪 Run tests
run: bun run test
80 changes: 0 additions & 80 deletions .github/workflows/upload-s3.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,4 @@ dist
.DS_Store

# Binary
werf-env-generator*
.werf_secret_key
3 changes: 3 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

npx --no -- commitlint --edit ${1}
9 changes: 9 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

BRANCH=$(git rev-parse --abbrev-ref HEAD)
REGEX="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)-[A-Z]{2,4}-[0-9]{1,5}-[A-Za-z0-9-]+$"

if ! [[ $BRANCH =~ $REGEX ]]; then
echo "Your commit was rejected due to branching name"
exit 1
fi
16 changes: 0 additions & 16 deletions .ops/taskfiles/system.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .ops/taskfiles/werf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,3 @@ tasks:
preconditions:
- sh: 'test -f .werf_secret_key'
msg: '.werf_secret_key file does not exist.'

# Utils: Check werf env generator
download-env-generator:
internal: true
desc: 'Check if werf-env-generate exists, if not, download it.'
vars:
OS: '{{.OS}}'
ARCH: '{{ "x64" | default .ARCH}}'
cmds:
- curl -O https://gbh-utils.s3.amazonaws.com/{{.OS}}/werf-env-generator-{{.ARCH}}
- mv werf-env-generator-{{.ARCH}} werf-env-generator
- chmod +x werf-env-generator
status:
- test -f werf-env-generator
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
awscli 2.17.4
bun 1.1.17
bun 1.1.21
werf 2.0.4
task 3.37.2
Binary file modified bun.lockb
Binary file not shown.
65 changes: 7 additions & 58 deletions cli.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,17 @@
#!/usr/bin/env bun

import { execSync } from 'node:child_process';
import { Command } from 'commander';
import yaml from 'js-yaml';
import { version } from './package.json';
import type { yamlDoc } from './src/interfaces';
import { generateEnvFile, mergeDataFromManifests } from './src/parser';
import { description, name, version } from './package.json';
import { werfCommand } from './src/commands/werf';
import { onePasswordCommand } from './src/commands/op';

const cli = new Command();

cli
.name('werf-env-file-generator')
.name(name)
.version(version)
.summary('Werf Env-File Generator CLI')
.option('-v,--values <variable>', 'Set extra environment values')
.requiredOption(
'-e, --environment <env>',
'Target environment for which to generate the .env file',
)
.option(
'-s, --secrets',
'Whether to include secret files in the Werf command',
true,
)
.option(
'-p, --to-path <path...>',
'Path(s) to generate the dot env (.env) file to',
['.env'],
)
.action((options) => {
const environment = options.environment.trim();

const werfCommand = [
'werf',
'render',
`--env ${environment}`,
`--values .helm/values/${environment}.yaml`,
'--dev',
];

if (options.secrets) {
werfCommand.push(`--secret-values .helm/secrets/${environment}.yaml`);
}

if (options.values) {
const extra_vars = options.values.trim();
werfCommand.push(`--set ${extra_vars}`);
}

console.log('Werf command:');
console.log(werfCommand);

const renderedManifests = execSync(werfCommand.join(' ').trim(), {
encoding: 'utf-8',
});

console.log('Obtaining env vars from rendered manifests...');
const manifests = yaml.loadAll(renderedManifests) as yamlDoc[];

const envData = mergeDataFromManifests(manifests);

for (const path of options.toPath) {
generateEnvFile(envData, path);
}
});
.summary(description)
.addCommand(werfCommand())
.addCommand(onePasswordCommand())

cli.parse();
Loading