Skip to content

Commit e79b6ef

Browse files
tillrwos
andcommitted
Chore: expand examples
- add quoting to ssh keys - add an example for preview apps - add an example workflow how to do housekeeping Co-authored-by: Richard Wossal <[email protected]>
1 parent c0cf019 commit e79b6ef

File tree

1 file changed

+86
-50
lines changed

1 file changed

+86
-50
lines changed

README.md

Lines changed: 86 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ A GitHub action to setup the runway CLI! Questions, issues? Please use discussio
77
## Quick Start
88

99
```yaml
10+
# ...
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
1015
- uses: hostwithquantum/[email protected]
1116
with:
1217
username: ${{ secrets.RUNWAY_USERNAME }}
@@ -34,11 +39,11 @@ Currently supported options:
3439

3540
## Examples
3641

37-
### Setup the runway CLI
42+
### Setup the runway CLI to deploy
3843

39-
This is an example how to setup the runway CLI and then how to deploy your app `cool-app`.
44+
This is an example workflow which shows runway CLI setup and then how to use the CLI to deploy your app `cool-app`.
4045

41-
Once you have the client setup, you can run commands and play around with output and so on. To keep it simple, we're only deploying the code. :) Since the app exists already on runway we use the `runway gitremote` command to initialize the setup.
46+
Once the client is setup, you can run all commands and play around with output and so on. To keep it simple, we're only deploying the code. :) Since the app exists already on runway we use the `runway gitremote` command to initialize the setup.
4247

4348
```yaml
4449
# .github/workflows/release.yml
@@ -55,27 +60,31 @@ jobs:
5560
env:
5661
YOUR_APPLICATION_NAME: cool-app
5762
steps:
58-
- uses: actions/checkout@v4
59-
with:
60-
fetch-depth: 0
61-
- name: create public/private key on GHA
62-
run: |
63-
mkdir -p ~/.ssh/
64-
echo ${{ secrets.PRIVATE_KEY }} > ~/.ssh/id_rsa
65-
echo ${{ secrets.PUBLIC_KEY }} > ~/.ssh/id_rsa.pub
66-
chmod 0600 ~/.ssh/id_rsa*
67-
- uses: hostwithquantum/[email protected]
68-
with:
69-
username: ${{ secrets.RUNWAY_USERNAME }}
70-
password: ${{ secrets.RUNWAY_PASSWORD }}
71-
setup-ssh: true
72-
- run: runway -y gitremote -a ${YOUR_APPLICATION_NAME}
73-
- run: runway -y app deploy
63+
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
- name: create public/private key on GHA
67+
run: |
68+
mkdir -p ~/.ssh/
69+
echo "${{ secrets.PRIVATE_KEY }}" > ~/.ssh/id_rsa
70+
echo "${{ secrets.PUBLIC_KEY }}" > ~/.ssh/id_rsa.pub
71+
chmod 0600 ~/.ssh/id_rsa*
72+
- uses: hostwithquantum/[email protected]
73+
with:
74+
username: ${{ secrets.RUNWAY_USERNAME }}
75+
password: ${{ secrets.RUNWAY_PASSWORD }}
76+
setup-ssh: true
77+
- run: runway -y gitremote -a ${YOUR_APPLICATION_NAME}
78+
- run: runway -y app deploy
7479
```
7580

7681
### Running e2e tests
7782

78-
GitHub Actions provides a robust and comprehensive environment. In the following workflow we leverage some of its context in form of `${{ github.run_id }} to deploy your app with a unique name. Once deployed, you can run end-to-end tests against it and in the end, shut it down by deleting the app (and key). :)
83+
GitHub Actions provides a robust and comprehensive environment to run e2e tests and here's how runway can help:
84+
85+
The following workflow leverages some of the context in form of `${{ github.run_id }}`. We'll use this _identifier_ to deploy an app with a unique name. Another viable option is to use the pull-requests's number: `${{ github.event.number }}`.
86+
87+
Once deployed, you can run end-to-end tests against it and in the end, shut it down by deleting the app (and key). :) If you decide to keep the application to have a preview available, you may also do that.
7988

8089
```yaml
8190
# .github/workflows/e2e.yml
@@ -90,34 +99,61 @@ jobs:
9099
runs-on: ubuntu-latest
91100
timeout-minutes: 15
92101
steps:
93-
- uses: actions/checkout@v4
94-
with:
95-
fetch-depth: 0 # this is important!
96-
- name: create an ssh key just for this run
97-
run: |
98-
mkdir -p ~/.ssh/
99-
ssh-keygen -b 2048 -t rsa -f ~/.ssh/test-runner -c "test-key-${{ github.run_id }}" -q -N ""
100-
- name: install CLI, login and add ssh key
101-
uses: hostwithquantum/[email protected]
102-
with:
103-
username: ${{ secrets.RUNWAY_USERNAME }}
104-
password: ${{ secrets.RUNWAY_PASSWORD }}
105-
public-key: ~/.ssh/test-runner.pub
106-
private-key: ~/.ssh/test-runner
107-
add-key: true
108-
setup-ssh: true
109-
- name: create app on runway (with a **unique name**)
110-
run: runway -y app create -a my-cool-app-${{ github.run_id }}
111-
- name: deploy your app to runway
112-
run: runway -y app deploy
113-
# this is where your tests run!
114-
- name: run your e2e tests here
115-
run: curl https://my-cool-app-${{ github.run_id }}.pqapp.dev/
116-
# then hopefully you are done :)
117-
- name: cleanup app
118-
if: always()
119-
run : runway -y app rm -a my-cool-app-${{ github.run_id }} || true
120-
- name: cleanup key - this is brute force
121-
if: always()
122-
run: runway -y key rm "test-key-${{ github.run_id }}" || true
102+
- uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0 # this is important!
105+
- name: create the application name
106+
run: echo "APP_NAME=my-app-${{ github.run_id }}" >> $GITHUB_ENV
107+
- name: create an ssh key just for this run
108+
run: |
109+
mkdir -p ~/.ssh/
110+
ssh-keygen -b 2048 -t rsa -f ~/.ssh/test-runner -c "test-key-${{ github.run_id }}" -q -N ""
111+
- name: install CLI, login and add ssh key
112+
uses: hostwithquantum/[email protected]
113+
with:
114+
username: ${{ secrets.RUNWAY_USERNAME }}
115+
password: ${{ secrets.RUNWAY_PASSWORD }}
116+
public-key: ~/.ssh/test-runner.pub
117+
private-key: ~/.ssh/test-runner
118+
add-key: true
119+
setup-ssh: true
120+
- name: create app on runway
121+
run: runway -y app create -a $APP_NAME || runway -y gitremote -a $APP_NAME
122+
- name: deploy your app to runway
123+
run: runway -y app deploy
124+
# this is where your tests run!
125+
- name: run your e2e tests here
126+
run: curl https://$APP_NAME.pqapp.dev/
127+
# then hopefully you are done :)
128+
- name: cleanup app
129+
if: always()
130+
run : runway -y app rm -a $APP_NAME || true
131+
- name: cleanup key - this is brute force
132+
if: always()
133+
run: runway -y key rm "test-key-${{ github.run_id }}" || true
134+
```
135+
136+
### Preview apps
137+
138+
In the previous example, we mentioned that keeping an app for people (humans!) to look at it, may be beneficial.
139+
140+
The following workflow expands on those concepts and deletes an application from runway when a pull-request is closed (merged or closed without merge). This example _assumes_ that you constructed the application name like, `my-app-${{ github.event.number }}` (instead of `github.run_id`).
141+
142+
```yaml
143+
name: delete app
144+
145+
on:
146+
pull_request:
147+
types:
148+
- closed
149+
150+
jobs:
151+
delete:
152+
runs-on: ubuntu-latest
153+
steps:
154+
- uses: hostwithquantum/[email protected]
155+
with:
156+
username: ${{ secrets.QUANTUM_RUNWAY_USERNAME }}
157+
password: ${{ secrets.QUANTUM_RUNWAY_PASSWORD }}
158+
- run: runway -y app delete my-app-${{ github.event.number }} || true
123159
```

0 commit comments

Comments
 (0)