Skip to content

Commit b115031

Browse files
authored
Gitpodify! (#3300)
1 parent ccff80f commit b115031

File tree

3 files changed

+65
-19
lines changed

3 files changed

+65
-19
lines changed

Diff for: .gitpod.Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# You can find the new timestamped tags here: https://hub.docker.com/r/gitpod/workspace-full/tags
2+
FROM gitpod/workspace-full:2022-05-08-14-31-53
3+
4+
USER root
5+
RUN cd /tmp && curl https://cli.pipedream.com/linux/amd64/latest/pd.zip --output pd.zip \
6+
&& unzip pd.zip -d /usr/local/bin

Diff for: .gitpod.yml

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
image:
2+
file: .gitpod.Dockerfile
3+
4+
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
5+
tasks:
6+
- name: Monorepo setup
7+
init: npm install --frozen-lockfile
8+
# openMode: split-left
9+
10+
- name: PD CLI
11+
command: printf "\033[3J\033c\033[3J" && pd
12+
# openMode: split-right
13+
14+
- command: gp ports await 23000 1>/dev/null && gp preview https://pipedream.com/docs/components/ && exit
15+
16+
- name: Init pipedream api key
17+
command: printf "\033[3J\033c\033[3J" && source scripts/gitpod_api_wizard.sh; exit
18+
119
github:
220
prebuilds:
321
master: true
@@ -7,22 +25,3 @@ github:
725
addCheck: false
826
addComment: false
927
addBadge: true
10-
11-
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
12-
tasks:
13-
- name: Monorepo setup
14-
init: npm install --frozen-lockfile
15-
# Installs the PD CLI and configures it to use the PD_API_KEY in the user's Gitpod settings
16-
# Add your ENV key here: https://gitpod.io/variables
17-
- name: Install PD CLI
18-
before: |
19-
curl https://cli.pipedream.com/linux/amd64/latest/pd.zip --output pd.zip && \
20-
unzip pd.zip -d pd && \
21-
sudo mv pd/pd /usr/local/bin/ && \
22-
rm -r pd && rm pd.zip
23-
init: |
24-
eval $(command gp env -e) &&
25-
mkdir ~/.config/pipedream &&
26-
touch ~/.config/pipedream/config &&
27-
echo "api_key = ${PD_API_KEY}" >> ~/.config/pipedream/config
28-
command: pd

Diff for: scripts/gitpod_api_wizard.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
function main() {
4+
eval $(command gp env -e);
5+
readonly api_key_name='PD_API_KEY';
6+
7+
function write_api_key() {
8+
local key="$1";
9+
local config_dir="$HOME/.config/pipedream";
10+
mkdir -p "$config_dir";
11+
printf 'api_key = %s\n' "$key" >> "$config_dir/config"
12+
}
13+
function log() {
14+
local kind="$1" && shift;
15+
printf '[%s]: %s\n' "$kind" "$@";
16+
}
17+
18+
if test -v "$api_key_name"; then {
19+
local -n api_key="$api_key_name";
20+
if test -n "$api_key"; then {
21+
write_api_key "$api_key";
22+
exit 0;
23+
} else {
24+
log error "$api_key_name is empty, go fix it at https://gitpod.io/variables";
25+
} fi
26+
} else {
27+
printf "\033[3J\033c\033[3J" # Clears the terminal
28+
log info "Get your Pipedream API key from:" \
29+
link "https://pipedream.com/settings/account > Programmatic Access" && printf '\n\n';
30+
31+
local api_key && read -rs -N 32 -p ">> Paste your pipedream API key: " api_key && printf '\n';
32+
log info "Adding your API_KEY to https://gitpod.io/variables" && {
33+
gp env "${api_key_name}=${api_key}" 1>/dev/null;
34+
}
35+
log info "Writing API_KEY to current workspace($GITPOD_WORKSPACE_ID) filesystem";
36+
write_api_key "$api_key";
37+
printf '\n\n>> %s' "API key setup complete! Press any key to contine ..." && read;
38+
exit 0;
39+
} fi
40+
} && main # Doesn't take any argument
41+
# To test for development: gp env -u PD_API_KEY; bash setup.sh

0 commit comments

Comments
 (0)