-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from molnett/initial
feat: initial commit
- Loading branch information
Showing
4 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: pr | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
- name: Molnctl Setup | ||
uses: molnett/setup-molnctl-action@v2 | ||
with: | ||
api-token-client-id: ${{ secrets.MOLNETT_CLIENT_ID }} | ||
api-token-client-secret: ${{ secrets.MOLNETT_CLIENT_SECRET }} | ||
default-org: personal | ||
- name: Deploy Ephemeral Environment | ||
uses: ./ | ||
with: | ||
action: deploy | ||
manifest-path: test/molnett.yaml | ||
- name: Delete Ephemeral environment | ||
uses: ./ | ||
with: | ||
action: delete | ||
manifest-path: test/molnett.yaml | ||
- name: Cleanup | ||
run: rm -r ~/.config/molnett |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @bittermandel @tmlye @mikn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: 'Molnett - Ephemeral Environments' | ||
description: 'Deploy or delete an ephemeral environment' | ||
branding: | ||
icon: 'download-cloud' | ||
color: 'orange' | ||
inputs: | ||
action: | ||
description: 'Either "deploy" or "delete"' | ||
required: true | ||
manifest-path: | ||
description: 'Path to molnett manifest' | ||
required: true | ||
outputs: | ||
environment-name: | ||
description: 'Name of the created environment' | ||
value: ${{ steps.env-name.outputs.env }} | ||
service-name: | ||
description: 'Name of the deployed service' | ||
value: ${{ steps.deploy.outputs.name }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check Event | ||
if: ${{ github.event_name != 'pull_request' }} | ||
shell: bash | ||
env: | ||
EVENT_NAME: ${{ github.event_name }} | ||
run: | | ||
echo "::error title=⛔ error hint::action needs pull request event, was $EVENT_NAME" | ||
exit 1 | ||
- name: Check Action | ||
if: ${{ inputs.action != 'deploy' && inputs.action != 'delete' }} | ||
shell: bash | ||
run: | | ||
echo "::error title=⛔ error hint::action needs to be deploy or delete" | ||
exit 1 | ||
- name: Check Runner OS | ||
if: ${{ runner.os != 'Linux' }} | ||
shell: bash | ||
run: | | ||
echo "::error title=⛔ error hint::Support Linux Only" | ||
exit 1 | ||
- name: Environment Name | ||
id: env-name | ||
shell: bash | ||
env: | ||
ENV_NAME: pr-${{ github.event.number }}-${{ github.head_ref }} | ||
run: | | ||
# Replace special characters in branch name with dash | ||
ENV_NAME=`echo $ENV_NAME | tr $'!\'#$%&()+,-./;<=>@]_\`{|}' '-'` | ||
echo "env=$ENV_NAME" >> $GITHUB_OUTPUT | ||
- name: Deploy Ephemeral Environment | ||
id: deploy | ||
if: ${{ inputs.action == 'deploy' }} | ||
shell: bash | ||
env: | ||
ENV_NAME: ${{ steps.env-name.outputs.env }} | ||
MANIFEST: ${{ inputs.manifest-path }} | ||
run: | | ||
sed -i "s/environment:.*/environment: $ENV_NAME/" $MANIFEST | ||
molnctl environments create $ENV_NAME || true | ||
molnctl services deploy --no-confirm $MANIFEST | ||
FINAL_NAME=$(sed -n 's/name: //p' $MANIFEST | awk '{$1=$1};1') | ||
echo "name=$FINAL_NAME" >> $GITHUB_OUTPUT | ||
- name: Delete Ephemeral Environment | ||
if: ${{ inputs.action == 'delete' }} | ||
shell: bash | ||
env: | ||
ENV_NAME: ${{ steps.env-name.outputs.env }} | ||
run: | | ||
molnctl environments delete --no-confirm $ENV_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
environment: ephemeral-test | ||
service: | ||
name: ephemeral-test | ||
image: nginx | ||
container_port: 8080 |