-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94cc662
commit ba22e76
Showing
7 changed files
with
213 additions
and
0 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,75 @@ | ||
name: Build & Deploy build on Iteiga | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
TAG_NAME: iteiga-deploy | ||
DEPLOY_DIR: ${{ secrets.ITEIGA_DEPLOY_DIR }} | ||
SSH_HOST: ${{ secrets.ITEIGA_SSH_HOST }} | ||
SSH_USER: ${{ secrets.ITEIGA_SSH_USER }} | ||
SSH_KEY: ${{ secrets.ITEIGA_SSH_KEY }} | ||
|
||
jobs: | ||
build_and_push: | ||
name: Build & Push Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Lowercase registry name | ||
run: | | ||
echo IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.CI_PAT }} | ||
submodules: recursive | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build & push Docker Image | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: . | ||
file: docker/Dockerfile | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }} | ||
deploy: | ||
needs: build_and_push | ||
name: Deploy to server | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.CI_PAT }} | ||
submodules: recursive | ||
|
||
- name: Setup SSH connection | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ env.SSH_KEY }} | ||
|
||
- name: Adding Known Hosts | ||
run: ssh-keyscan -H ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts | ||
|
||
- name: Login to the GitHub Packages Docker Registry | ||
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Copy docker compose | ||
run: scp docker/docker-compose.yml ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:${{ env.DEPLOY_DIR }}/docker-compose.yml | ||
|
||
- name: Copy deploy script | ||
run: scp deploy.sh ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:${{ env.DEPLOY_DIR }}/deploy.sh | ||
|
||
- name: Run deploy script | ||
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "cd ${{ env.DEPLOY_DIR }} && chmod +x deploy.sh && ./deploy.sh" | ||
|
||
- name: Logout of package registry | ||
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "docker logout ${{ env.REGISTRY }}" |
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,75 @@ | ||
name: Build & Deploy build on Pluvio | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
TAG_NAME: pluvio-deploy | ||
DEPLOY_DIR: ${{ secrets.PLUVIO_DEPLOY_DIR }} | ||
SSH_HOST: ${{ secrets.PLUVIO_SSH_HOST }} | ||
SSH_USER: ${{ secrets.PLUVIO_SSH_USER }} | ||
SSH_KEY: ${{ secrets.PLUVIO_SSH_KEY }} | ||
|
||
jobs: | ||
build_and_push: | ||
name: Build & Push Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Lowercase registry name | ||
run: | | ||
echo IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.CI_PAT }} | ||
submodules: recursive | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build & push Docker Image | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: . | ||
file: docker/Dockerfile | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }} | ||
deploy: | ||
needs: build_and_push | ||
name: Deploy to server | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.CI_PAT }} | ||
submodules: recursive | ||
|
||
- name: Setup SSH connection | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ env.SSH_KEY }} | ||
|
||
- name: Adding Known Hosts | ||
run: ssh-keyscan -H ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts | ||
|
||
- name: Login to the GitHub Packages Docker Registry | ||
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Copy docker compose | ||
run: scp docker/docker-compose.yml ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:${{ env.DEPLOY_DIR }}/docker-compose.yml | ||
|
||
- name: Copy deploy script | ||
run: scp deploy.sh ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:${{ env.DEPLOY_DIR }}/deploy.sh | ||
|
||
- name: Run deploy script | ||
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "cd ${{ env.DEPLOY_DIR }} && chmod +x deploy.sh && ./deploy.sh" | ||
|
||
- name: Logout of package registry | ||
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "docker logout ${{ env.REGISTRY }}" |
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,24 @@ | ||
images=() | ||
|
||
simple_deploy() { | ||
service_name=$1 | ||
old_container_id=$(docker ps -f name=$service_name -aq | tail -n1) | ||
|
||
images+=($(docker inspect --format='{{.Image}}' $(docker ps -aq -f name=$service_name) | sed s/sha256://)) | ||
|
||
if [ $( docker ps -f name=$service_name -aq | wc -l ) -gt 0 ]; then | ||
# take the old container offline | ||
docker stop $old_container_id 1> /dev/null | ||
docker rm $old_container_id 1> /dev/null | ||
fi | ||
|
||
docker compose up -d --no-recreate --no-build --pull always $service_name | ||
} | ||
|
||
simple_deploy ppbot | ||
|
||
for image in ${images[@]}; do | ||
docker image rm $image &> /dev/null || true | ||
done | ||
|
||
|
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,9 @@ | ||
**/.env | ||
**/node_modules | ||
**/.git | ||
**/Dockerfile | ||
**/docker-compose.yml | ||
**/.prettierrc | ||
**/.gitignore | ||
**/.eslintrc.js | ||
**/README.md |
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,2 @@ | ||
IMAGE_NAME = ghcr.io/scoresaber/scoresaber-ppbot:prod-deploy | ||
CONFIG_FILE_PPBOT = |
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,7 @@ | ||
FROM node:20-bullseye-slim | ||
|
||
# create app directory | ||
WORKDIR /usr/src/app | ||
COPY . /usr/src/app/ | ||
RUN npm install | ||
RUN npm run build |
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,21 @@ | ||
services: | ||
ppbot: | ||
image: '${IMAGE_NAME}' | ||
container_name: ppbot | ||
command: node dist/index.js | ||
networks: | ||
- scoresaber-network | ||
extra_hosts: | ||
- 'host.docker.internal:host-gateway' | ||
volumes: | ||
- type: bind | ||
source: '${CONFIG_FILE_PPBOT}' | ||
target: /usr/src/app/.env | ||
restart: on-failure | ||
build: | ||
context: .. | ||
dockerfile: docker/Dockerfile | ||
networks: | ||
scoresaber-network: | ||
name: scoresaber-network | ||
driver: bridge |