Skip to content

Commit

Permalink
added deploy pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
NivEz committed Aug 11, 2023
1 parent 2c3f6c8 commit 39920af
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 48 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build and deploy

on:
push:
branches: [ main ]

env:
DOCKER_USERNAME: nivezra

jobs:
build:
# if: "false"
runs-on: ubuntu-latest
permissions:
contents: write
env:
DOCKER_REPO_CLIENT: nivezra/super-bulb-client
DOCKER_REPO_SERVER: nivezra/super-bulb-server
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker images
run: |
# COMPOSE_DOCKER_CLI_BUILD=1 \
# DOCKER_BUILDKIT=1 \
# DOCKER_DEFAULT_PLATFORM=linux/arm64 \
# docker compose build
docker buildx build --platform linux/arm64 -t $DOCKER_REPO_CLIENT:latest --output type=docker ./client
docker buildx build --platform linux/arm64 -t $DOCKER_REPO_SERVER:latest --output type=docker ./server
docker images
- name: Bump version and push tag
id: bump
uses: anothrNick/github-tag-action@1.64.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch

- name: Tag Docker images
run: |
docker tag $DOCKER_REPO_CLIENT:latest $DOCKER_REPO_CLIENT:${{ steps.bump.outputs.new_tag }}
docker tag $DOCKER_REPO_SERVER:latest $DOCKER_REPO_SERVER:${{ steps.bump.outputs.new_tag }}
- name: Push Docker images
run: |
docker push $DOCKER_REPO_CLIENT --all-tags
docker push $DOCKER_REPO_SERVER --all-tags
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Twingate
uses: twingate/github-action@v1
with:
# note that the service key is valid for 365 days
service-key: ${{ secrets.TWINGATE_SERVICE_KEY }}

- name: SCP docker-compose file
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: "docker-compose.yaml"
target: "~/super-bulb/"

- name: Deploy containers via SSH
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd super-bulb
docker compose pull
docker compose up -d
47 changes: 0 additions & 47 deletions .github/workflows/build.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,19 @@
resolved "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz"
integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==

"@irojs/iro-core@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@irojs/iro-core/-/iro-core-1.2.1.tgz#ab45cf0899717fae785ef9661b82bb6f78cd3748"
integrity sha512-p2OvsBSSmidsDsTSkID6jEyXDF7lcyxPrkh3qBzasBZFpjkYd6kZ3yMWai3MlAaQ3F7li/Et7rSJVV09Fpei+A==

"@jaames/iro@^5.5.2":
version "5.5.2"
resolved "https://registry.yarnpkg.com/@jaames/iro/-/iro-5.5.2.tgz#15301c19080b985aede06c5f07867aa20d06e679"
integrity sha512-Fbi5U4Vdkw6UsF+R3oMlPONqkvUDMkwzh+mX718gQsDFt3+1r1jvGsrfCbedmXAAy0WsjDHOrefK0BkDk99TQg==
dependencies:
"@irojs/iro-core" "^1.2.1"
preact "^10.0.0"

"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
version "0.3.3"
resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz"
Expand Down Expand Up @@ -574,6 +587,11 @@ postcss@^8.4.23:
picocolors "^1.0.0"
source-map-js "^1.0.2"

preact@^10.0.0:
version "10.16.0"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.16.0.tgz#68a06d70b191b8a313ea722d61e09c6b2a79a37e"
integrity sha512-XTSj3dJ4roKIC93pald6rWuB2qQJO9gO2iLLyTe87MrjQN+HklueLsmskbywEWqCHlclgz3/M4YLL2iBr9UmMA==

react-dom@^18.2.0:
version "18.2.0"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz"
Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY . /app/

EXPOSE 6543

ENTRYPOINT ["python", "websocket.py"]
ENTRYPOINT ["python", "-u", "websocket.py"]

0 comments on commit 39920af

Please sign in to comment.