Merge branch 'guildScheduledEvents' into development #14
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
name: TestBuildAndDeploy | |
on: | |
push: | |
branches: [development] | |
release: | |
types: [created] | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
SERVER_HOST: ${{ secrets.SSH_HOST }} | |
SERVER_USERNAME: ${{ secrets.SSH_USERNAME }} | |
SERVER_PASSWORD: ${{ secrets.SSH_PASSWORD }} | |
SERVER_KEY: ${{ secrets.SSH_KEY }} | |
CLIENT_ID: ${{ secrets.CLIENT_ID }} | |
GUILD_ID: ${{ secrets.GUILD_ID }} | |
MONGO_CONNECTION_LINK: ${{ secrets.MONGO_CONNECTION_LINK }} | |
TOKEN: ${{ secrets.TOKEN }} | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint code | |
run: npm run lint | |
- name: Lint Dockerfile | |
run: docker run --rm -i hadolint/hadolint < Dockerfile | |
- name: Set up Docker Buildx | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
context: . | |
file: ./Dockerfile | |
tags: uwrksi/ksicius:latest | |
build-args: | | |
MONGO_CONNECTION_LINK=${{ env.MONGO_CONNECTION_LINK }} | |
CLIENT_ID=${{ env.CLIENT_ID }} | |
GUILD_ID=${{ env.GUILD_ID }} | |
TOKEN=${{ env.TOKEN }} | |
- name: SSH into server and deploy | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
uses: appleboy/[email protected] | |
env: | |
USERNAME: ${{ env.DOCKER_USERNAME }} | |
PASSWORD: ${{ env.DOCKER_PASSWORD }} | |
with: | |
host: ${{ env.SERVER_HOST }} | |
username: ${{ env.SERVER_USERNAME }} | |
password: ${{ env.SERVER_PASSWORD }} | |
key: ${{ env.SERVER_KEY }} | |
envs: USERNAME, PASSWORD | |
script: | | |
docker login -u $USERNAME -p $PASSWORD | |
docker pull uwrksi/ksicius:latest | |
docker stop ksicius || true | |
docker rm ksicius || true | |
docker run -d --restart=always --name ksicius uwrksi/ksicius:latest |