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

Add oranda #57

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 8 additions & 11 deletions .env-select.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[applications.server.profiles.base]
variables = {PROTOCOL = "https"}

[applications.server.profiles.dev]
extends = ["base"]
variables = {SERVICE1 = "dev", SERVICE2 = "also-dev"}
[applications.server.profiles.base1]
pre_export = [{setup = "echo base1 setup", teardown = "echo base1 teardown"}]

[applications.server.profiles.prd]
extends = ["base"]
[applications.server.profiles.prd.variables]
SERVICE1 = "prd"
SERVICE2 = "also-prd"
SERVICE3 = {type = "file", path = "creds.env", multiple = true}
[applications.server.profiles.base2]
pre_export = [{setup = "echo base2 setup", teardown = "echo base2 teardown"}]

[applications.server.profiles.child]
extends = ["base1", "base2"]
pre_export = [{setup = "echo child setup", teardown = "echo child teardown"}]
98 changes: 98 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Workflow to build your docs with oranda (and mdbook)
# and deploy them to Github Pages
name: Web

# We're going to push to the gh-pages branch, so we need that permission
permissions:
contents: write

# What situations do we want to build docs in?
# All of these work independently and can be removed / commented out
# if you don't want oranda/mdbook running in that situation
on:
# Check that a PR didn't break docs!
#
# Note that the "Deploy to Github Pages" step won't run in this mode,
# so this won't have any side-effects. But it will tell you if a PR
# completely broke oranda/mdbook. Sadly we don't provide previews (yet)!
pull_request:

# Whenever something gets pushed to main, update the docs!
# This is great for getting docs changes live without cutting a full release.
#
# Note that if you're using cargo-dist, this will "race" the Release workflow
# that actually builds the Github Release that oranda tries to read (and
# this will almost certainly complete first). As a result you will publish
# docs for the latest commit but the oranda landing page won't know about
# the latest release. The workflow_run trigger below will properly wait for
# cargo-dist, and so this half-published state will only last for ~10 minutes.
#
# If you only want docs to update with releases, disable this, or change it to
# a "release" branch. You can, of course, also manually trigger a workflow run
# when you want the docs to update.
push:
branches:
- main

# Whenever a workflow called "Release" completes, update the docs!
#
# If you're using cargo-dist, this is recommended, as it will ensure that
# oranda always sees the latest release right when it's available. Note
# however that Github's UI is wonky when you use workflow_run, and won't
# show this workflow as part of any commit. You have to go to the "actions"
# tab for your repo to see this one running (the gh-pages deploy will also
# only show up there).
workflow_run:
workflows: [ "Release" ]
types:
- completed

# Alright, let's do it!
jobs:
web:
name: Build and deploy site and docs
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v2

# If you use any mdbook plugins, here's the place to install them!

# Install and run oranda (and mdbook)
# This will write all output to ./public/ (including copying mdbook's output to there)
- name: Install and run oranda
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.6.1/oranda-installer.sh | sh
oranda build

- name: Prepare HTML for link checking
# untitaker/hyperlink supports no site prefixes, move entire site into
# a subfolder
run: mkdir /tmp/public/ && cp -R public /tmp/public/oranda

- name: Check HTML for broken internal links
uses: untitaker/[email protected]
with:
args: /tmp/public/

# Deploy to our gh-pages branch (creating it if it doesn't exist)
# the "public" dir that oranda made above will become the root dir
# of this branch.
#
# Note that once the gh-pages branch exists, you must
# go into repo's settings > pages and set "deploy from branch: gh-pages"
# the other defaults work fine.
- name: Deploy to Github Pages
uses: JamesIves/[email protected]
# ONLY if we're on main (so no PRs or feature branches allowed!)
if: ${{ github.ref == 'refs/heads/main' }}
with:
branch: gh-pages
# Gotta tell the action where to find oranda's output
folder: public
token: ${{ secrets.GITHUB_TOKEN }}
single-commit: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/target

# Generated by `oranda generate ci`
public/
69 changes: 6 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
![license](https://img.shields.io/github/license/LucasPickering/env-select)
[![crates.io version](https://img.shields.io/crates/v/env-select.svg)](https://crates.io/crates/env-select)

- [Home Page](https://env-select.lucaspickering.me)
- [Installation](https://env-select.lucaspickering.me/artifacts/)
- [Docs](https://env-select.lucaspickering.me/book/)
- [Changelog](https://env-select.lucaspickering.me/changelog/)

Easily switch between predefined values for arbitrary environment variables Features include (but are not limited to):

- Interative prompts to select between variable profiles
Expand All @@ -11,16 +16,7 @@ Easily switch between predefined values for arbitrary environment variables Feat
- Modify your shell environment with `es set`, or run a one-off command in a modified environment with `es run`
- Re-use common variables between profiles with inheritance

## Table of Contents

- [Simple Example](#simple-example)
- [Installation](#installation)
- [Usage Guide](USAGE.md)
- [Disclaimer](#source-disclaimer)
- [Troubleshooting](#troubleshooting)
- [Bugs/Feedback](#bugsfeedback)

## Simple Example
## Example

```toml
# .env-select.toml
Expand All @@ -44,65 +40,12 @@ SERVICE2=also-prd
dev also-dev
```

See the [Usage Guide](USAGE.md) for more detailed examples.

## Installation

### Brew

```sh
brew install lucaspickering/tap/env-select
```

### Cargo

```sh
cargo install env-select
```

### Configure Your Shell

**This may not be necessary, depending on what shell you use and how you installed env-select.** The easiest way to check is to open a new shell and run `es help`. If it succeeds, you're good to go. If not, read on.

Because env-select modifies your shell environment, it requires a wrapper function defined in the shell that can call the `env-select` binary and automatically apply its output.

**All commands in this README/usage guide assume you have the appropriate shell configuration.** See [the disclaimer](#source-disclaimer) for why this is needed.

#### Bash

```sh
echo 'eval "$(env-select --shell bash init)"' >> ~/.bashrc
source ~/.bashrc # Run this in every existing shell
```

#### Zsh

```sh
echo 'source <(env-select --shell zsh init)' >> ~/.zshrc
source ~/.zshrc # Run this in every existing shell
```

#### Fish

```sh
echo 'env-select --shell fish init | source' >> ~/.config/fish/config.fish
source ~/.config/fish/config.fish # Run this in every existing shell
```

**Restart your shell (or `source <file>`) after running the above command.**

## `source` Disclaimer

env-select runs as a subprocess to your shell (as all commands do), meaning it cannot modify your shell environment. To get around this, env-select will simply output shell commands that the shell plugins (or you) can then pipe to `source` (or `eval`) to modify your session.

If you think piping stuff to `source` is dangerous and sPoOky, you're right. But consider the fact that at this point, you've already downloaded and executed a mystery binary on your machine. You should've already done your due diligence.

## Troubleshooting

### `es: command not found`

Make sure you've [configured your shell](#configure-your-shell) to load the `es` function automatically.

## Bugs/Feedback

If you find a bug or have a feature request, please [open an issue on GitHub](https://github.com/LucasPickering/env-select/issues/new).
Loading
Loading