-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
95 lines (85 loc) · 2.69 KB
/
action.yml
File metadata and controls
95 lines (85 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: "Setup Swamp"
description: "Download and install swamp, optionally authenticate with swamp.club and initialize a repository"
branding:
icon: "terminal"
color: "green"
inputs:
version:
description: "Swamp version to install (default: stable)"
required: false
default: "stable"
api-key:
description: "API key for authenticating with swamp.club (set as SWAMP_API_KEY env var)"
required: false
swamp-club-url:
description: "Override the swamp.club server URL (default: https://swamp.club)"
required: false
repo-init:
description: "Run swamp repo init after setup"
required: false
default: "false"
outputs:
version:
description: "The version of swamp that was installed"
value: ${{ steps.verify.outputs.version }}
runs:
using: "composite"
steps:
- name: Install swamp
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
INSTALL_DIR="${RUNNER_TEMP}/swamp"
mkdir -p "${INSTALL_DIR}"
curl -sSfL https://artifacts.systeminit.com/install.sh | sh -s -- \
-V "$INPUT_VERSION" \
-d "$INSTALL_DIR"
echo "${INSTALL_DIR}" >> "$GITHUB_PATH"
- name: Verify installation
id: verify
shell: bash
run: |
VERSION=$(swamp --version)
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Installed swamp ${VERSION}"
- name: Mask and set SWAMP_API_KEY
if: inputs.api-key != ''
shell: bash
env:
SWAMP_API_KEY: ${{ inputs.api-key }}
run: |
# Reject values containing newlines to prevent GITHUB_ENV injection
if [[ "$SWAMP_API_KEY" == *$'\n'* ]]; then
echo "::error::api-key must not contain newlines"
exit 1
fi
echo "::add-mask::${SWAMP_API_KEY}"
echo "SWAMP_API_KEY=${SWAMP_API_KEY}" >> "$GITHUB_ENV"
- name: Set SWAMP_CLUB_URL
if: inputs.swamp-club-url != ''
shell: bash
env:
SWAMP_CLUB_URL: ${{ inputs.swamp-club-url }}
run: |
# Reject values containing newlines to prevent GITHUB_ENV injection
if [[ "$SWAMP_CLUB_URL" == *$'\n'* ]]; then
echo "::error::swamp-club-url must not contain newlines"
exit 1
fi
# Validate URL scheme
if [[ "$SWAMP_CLUB_URL" != https://* ]]; then
echo "::error::swamp-club-url must use https://"
exit 1
fi
echo "SWAMP_CLUB_URL=${SWAMP_CLUB_URL}" >> "$GITHUB_ENV"
- name: Verify authentication
if: inputs.api-key != ''
shell: bash
run: |
swamp auth whoami
- name: Initialize repository
if: inputs.repo-init == 'true'
shell: bash
run: |
swamp repo init