Skip to content

Commit

Permalink
feat: add tailscale to github action (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRampoldi authored Apr 9, 2024
1 parent 49886d4 commit b8d04ff
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/production-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:

Build:
Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -29,22 +29,31 @@ jobs:
Deploy:
name: Deploy to server
runs-on: ubuntu-latest
needs: [Build]
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
needs: [Test]

steps:
- name: Deploy to server
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
HOST_NAME: ${{ secrets.HOST_NAME }}
USER_NAME: ${{ secrets.USER_NAME }}
APP_DIR: ${{ secrets.APP_DIR }}
SERVICE_NAME: ${{ secrets.SERVICE_NAME }}
run:
echo "$PRIVATE_KEY" > private_key &&
chmod 400 private_key &&
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOST_NAME} "
cd ${APP_DIR} &&
sudo systemctl stop ${SERVICE_NAME} &&
git pull &&
sudo systemctl start ${SERVICE_NAME} "
- name: Connect Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ vars.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci

- name: Deploy to server
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
HOST_NAME: ${{ vars.HOST_NAME }}
USER_NAME: ${{ secrets.USER_NAME }}
APP_DIR: ${{ vars.APP_DIR }}
SERVICE_NAME: ${{ vars.SERVICE_NAME }}
run:
echo "$PRIVATE_KEY" > private_key &&
chmod 400 private_key &&
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOST_NAME} "
cd ${APP_DIR} &&
sudo systemctl stop ${SERVICE_NAME} &&
git pull &&
/usr/local/go/bin/go install ./... &&
/usr/local/go/bin/go build -o yab-explorer ./cmd &&
/home/ubuntu/go/bin/swag init -g ./cmd/main.go -o ./docs &&
sudo systemctl start ${SERVICE_NAME} "

0 comments on commit b8d04ff

Please sign in to comment.