-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
104 lines (94 loc) · 3.15 KB
/
action.yml
File metadata and controls
104 lines (94 loc) · 3.15 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
96
97
98
99
100
101
102
103
104
name: 'Setup Strong-Opx'
description: 'Install and Configure Strong-OpX'
inputs:
version:
description: 'Strong-OpX version to use. If not provided, the version of the action will be used.'
default: ''
python-version:
description: 'Python version to use'
default: '3.12'
provider:
description: 'Provider to use'
default: 'aws'
project-path:
description: 'Project path'
required: true
ssh-user:
description: 'SSH username'
default: ''
ssh-key:
description: 'SSH key'
default: ''
git-ssh-key:
description: 'SSH key to use for pulling source code during deployment'
default: ''
outputs:
executable:
description: 'strong-opx executable path'
value: ${{ steps.path.outputs.executable-path }}
runs:
using: composite
steps:
- uses: actions/setup-python@v4
with:
python-version: "${{ inputs.python-version }}"
- name: Extract version tag from action reference
id: get-version
run: |
if [ "${{ env.ACTION_REF }}" == "v*" ] && [ -z "${{ inputs.version }}" ]; then
# Extract version from github.action_ref (e.g., v1.2 from strongio/strong-opx@v1.2)
VERSION=$(echo "${{ env.ACTION_REF }}" | sed 's/^v//')
else
VERSION="${{ inputs.version }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
shell: bash
env:
ACTION_REF: ${{ github.action_ref }}
# - name: cache venv
# id: cache
# uses: actions/cache@v3
# with:
# path: /opt/strong-opx
# key: "strong-opx-${{ steps.get-version.outputs.version }}"
- name: create venv
# if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: python -m venv /opt/strong-opx
- name: set env vars
shell: bash
run: |
source /opt/strong-opx/bin/activate
echo "PATH=$PATH" >> $GITHUB_ENV
- name: install strong-opx
shell: bash
run: |
source /opt/strong-opx/bin/activate
if [ -z "${{ steps.get-version.outputs.version }}" ]; then
pip install "strong-opx[${{ inputs.provider }}]"
else
pip install "strong-opx[${{ inputs.provider }}]==${{ steps.get-version.outputs.version }}"
fi
- name: register project
shell: bash
run: strong-opx project register "${{ inputs.project-path }}"
- name: configure ssh for strong-opx
if: ${{ inputs.ssh-key }}
shell: bash
run: |
install -m 700 -d ~/.ssh
install -m 644 /dev/null ~/.ssh/config
install -m 600 <(echo "${{ inputs.ssh-key }}") ~/.ssh/strong-opx-ssh
printf "Host *\n\tStrictHostKeyChecking no" >> ~/.ssh/config
strong-opx config ssh.user ${{ inputs.ssh-user }}
strong-opx config ssh.key ~/.ssh/strong-opx-ssh
- name: configure git credentials for strong-opx
if: ${{ inputs.git-ssh-key }}
shell: bash
run: |
install -m 600 <(echo "${{ inputs.git-ssh-key }}") ~/.ssh/strong-opx-git-ssh
strong-opx config git.ssh.key ~/.ssh/strong-opx-git-ssh
- name: get strong-opx executable path
id: path
shell: bash
run: echo "executable-path=$(which strong-opx)" >> $GITHUB_OUTPUT