Added project architecture and initial structure #14
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
branches: [ main, master ] | |
env: | |
IMAGE_NAME: "auth" | |
CONTAINER_NAME: "auth" | |
jobs: | |
image-build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Registery | |
run: echo ${{ secrets.CREADS }} | docker login --username AWS --password-stdin ${{ secrets.REGISTRY }} | |
- name: Build and Push Docker Image | |
run: | | |
TAG_NAME=$(echo $GITHUB_SHA | head -c7) | |
docker buildx create --use | |
docker buildx build --no-cache --push --tag ${{ secrets.REGISTRY }}/$IMAGE_NAME:$TAG_NAME -f ./Dockerfile . | |
deploy-image: | |
runs-on: ubuntu-latest | |
needs: image-build-and-push | |
steps: | |
- name: Deploy to Selectel Cloud via SSH action | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSHKEY }} | |
envs: IMAGE_NAME,GITHUB_SHA,CONTAINER_NAME | |
script: | | |
# Set up variables | |
TAG_NAME=$(echo $GITHUB_SHA | head -c7) | |
# Login into Selectel Registry | |
echo ${{ secrets.CREADS }} | docker login --username AWS --password-stdin ${{ secrets.REGISTRY }} | |
# Stop running container | |
docker stop $CONTAINER_NAME | |
# Remove old container | |
docker rm $CONTAINER_NAME | |
# Run a new container from a new image | |
docker run -d -p 50051:50051 --name $CONTAINER_NAME -t ${{ secrets.REGISTRY }}/$IMAGE_NAME:$TAG_NAME |