-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy main branch to next.esm.sh (#908)
- Loading branch information
Showing
12 changed files
with
150 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
name: Deploy main branch to next.esm.sh | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.23.x | ||
|
||
- name: Run `deploy-ci.sh` | ||
run: scripts/deploy-ci.sh | ||
env: | ||
GOOS: linux | ||
GOARCH: ${{ secrets.DEPLOY_HOST_ARCH }} | ||
SSH_HOST_NAME: ${{ secrets.DEPLOY_SSH_HOST_NAME }} | ||
SSH_USER: ${{ secrets.DEPLOY_SSH_USER }} | ||
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
scriptDir=$(dirname $0) | ||
|
||
echo "--- building..." | ||
go build -o $scriptDir/esmd $scriptDir/../main.go | ||
if [ "$?" != "0" ]; then | ||
exit | ||
fi | ||
|
||
mkdir -p ~/.ssh | ||
echo "${SSH_PRIVATE_KEY}" >> ~/.ssh/id_ed25519 | ||
echo "next.esm.sh" >> ~/.ssh/config | ||
echo " HostName ${SSH_HOST_NAME}" >> ~/.ssh/config | ||
echo " User ${SSH_USER}" >> ~/.ssh/config | ||
echo " IdentityFile ~/.ssh/id_ed25519" >> ~/.ssh/config | ||
echo " IdentitiesOnly yes" >> ~/.ssh/config | ||
|
||
echo "--- uploading..." | ||
tar -czf esmd.tar.gz esmd | ||
scp esmd.tar.gz next.esm.sh:/tmp/esmd.tar.gz | ||
if [ "$?" != "0" ]; then | ||
exit | ||
fi | ||
|
||
echo "--- installing..." | ||
ssh next.esm.sh << EOF | ||
cd /tmp | ||
tar -xzf esmd.tar.gz | ||
if [ "\$?" != "0" ]; then | ||
exit | ||
fi | ||
rm -rf esmd.tar.gz | ||
supervisorctl version | ||
if [ "\$?" != "0" ]; then | ||
apt update | ||
apt install -y supervisor git git-lfs | ||
fi | ||
svcf=/etc/supervisor/conf.d/esmd.conf | ||
reload=no | ||
if [ ! -f \$svcf ]; then | ||
echo "[program:esmd]" >> \$svcf | ||
echo "command=/usr/local/bin/esmd" >> \$svcf | ||
echo "directory=/tmp" >> \$svcf | ||
echo "user=${SSH_USER}" >> \$svcf | ||
echo "autostart=true" >> \$svcf | ||
echo "autorestart=true" >> \$svcf | ||
reload=yes | ||
if | ||
supervisorctl stop esmd | ||
rm -f /usr/local/bin/esmd | ||
mv -f esmd /usr/local/bin/esmd | ||
chmod +x /usr/local/bin/esmd | ||
if [ "\$?" != "0" ]; then | ||
exit | ||
fi | ||
if [ "\$reload" == "yes" ]; then | ||
supervisorctl reload | ||
else | ||
supervisorctl start esmd | ||
fi | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters