Skip to content

Commit ab99851

Browse files
committed
New version
0 parents  commit ab99851

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
keys

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# GitHub Action to deploy Node.js, Python, PHP and more to Stackhero
2+
3+
See [https://www.stackhero.io/en/stackhero/documentations](https://www.stackhero.io/en/stackhero/documentations)
4+
5+
6+
## Deploy a new version
7+
8+
```bash
9+
reason="New version"
10+
git add -A .
11+
git commit -m "${reason}"
12+
git tag -a v1 -m "${reason}"
13+
git push --follow-tags
14+
```

action.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy to Stackhero
2+
# run-name: Deploy branch ${{ github.ref_name }} to Stackhero
3+
description: Deploy your code to a Stackhero instance
4+
5+
6+
inputs:
7+
ssh_private_key:
8+
description: 'Your SSH private key'
9+
required: true
10+
11+
endpoint:
12+
description: 'Endpoint of your instance (xxxxxx.stackhero-network.com or your customized domain)'
13+
required: true
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Check inputs
21+
shell: bash
22+
run: |
23+
error=0
24+
25+
if [ "${{ inputs.ssh_private_key }}" = "" ]
26+
then
27+
echo "::error::The \"ssh_private_key\" argument should be passed to this action."
28+
error=1
29+
fi
30+
31+
if [ "${{ inputs.endpoint }}" = "" ]
32+
then
33+
echo "::error::The \"endpoint\" argument should be passed to this action."
34+
error=1
35+
fi
36+
37+
if [ "$error" == 1 ]
38+
then
39+
exit 1
40+
fi
41+
42+
- name: Configure SSH
43+
shell: bash
44+
run: |
45+
install -m 600 -D /dev/null ~/.ssh/private_key
46+
echo "${{ inputs.ssh_private_key }}" > ~/.ssh/private_key
47+
git config --local --add core.sshCommand 'ssh -i ~/.ssh/private_key'
48+
49+
ssh-keyscan -p 222 ${{ inputs.endpoint }} > ~/.ssh/known_hosts
50+
51+
- name: Configure GIT
52+
shell: bash
53+
run: |
54+
git config --global user.email "actions@github.com"
55+
git config --global user.name "GitHub actions"
56+
57+
- name: Deploy
58+
shell: bash
59+
run: |
60+
git fetch --unshallow origin
61+
git remote add stackhero ssh://stackhero@${{ inputs.endpoint }}:222/project.git
62+
63+
git push -f stackhero ${{ github.ref_name }}:main

0 commit comments

Comments
 (0)