-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,123 @@ | ||
#name: CI | ||
##Check your CI/CD configuration with the following command: | ||
## docker-compose -f internal/config/docker-compose.yaml config | ||
#on: | ||
# push: | ||
# branches: [ main, master ] | ||
# pull_request: | ||
# branches: [ main, master ] | ||
# | ||
#env: | ||
# REGISTRY: "cr.selcloud.ru/andyregistry" | ||
# IMAGE_NAME: "crud-server" | ||
# CONTAINER_NAME: "crud-server-container" | ||
# | ||
#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 Registry | ||
# run: docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} $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 $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,REGISTRY,GITHUB_SHA,CONTAINER_NAME | ||
# script: | | ||
# # Set up variables | ||
# TAG_NAME=$(echo $GITHUB_SHA | head -c7) | ||
# | ||
# # Login into Selectel Registry | ||
# docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} $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 $REGISTRY/$IMAGE_NAME:$TAG_NAME | ||
|
||
name: CI | ||
#Check your CI/CD configuration with the following command: | ||
# docker-compose -f internal/config/docker-compose.yaml config | ||
|
||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
|
||
env: | ||
REGISTRY: "cr.selcloud.ru/andyregistry" | ||
IMAGE_NAME: "crud-server" | ||
CONTAINER_NAME: "crud-server-container" | ||
REGISTRY: "cr.selcloud.ru/microservices" | ||
IMAGE_NAME: "chat-server" | ||
CONTAINER_NAME: "chat-server-container" | ||
|
||
jobs: | ||
image-build-and-push: | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Checkout master | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Registry | ||
run: docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} $REGISTRY | ||
|
||
- name: Build and Push Docker Image | ||
run: | | ||
TAG_NAME=$(echo $GITHUB_SHA | head -c7) | ||
TAG=$(echo $GITHUB_SHA | head -c7) | ||
docker buildx create --use | ||
docker buildx build --no-cache --push --tag $REGISTRY/$IMAGE_NAME:$TAG_NAME -f Dockerfile . | ||
docker buildx build --no-cache --push --tag $REGISTRY/$IMAGE_NAME:$TAG --build-arg="ENV=stage" --build-arg="CONFIG=stage.env" . | ||
deploy-image: | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
needs: image-build-and-push | ||
|
||
steps: | ||
- name: Deploy to Selectel Cloud via SSH action | ||
uses: appleboy/[email protected].0 | ||
uses: appleboy/[email protected].3 | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSHKEY }} | ||
key: ${{ secrets.SSH_KEY }} | ||
passphrase: ${{ secrets.SSH_KEY_PASSPHRASE }} | ||
envs: IMAGE_NAME,REGISTRY,GITHUB_SHA,CONTAINER_NAME | ||
script: | | ||
# Set up variables | ||
TAG_NAME=$(echo $GITHUB_SHA | head -c7) | ||
# Login into Selectel Registry | ||
docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} $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 $REGISTRY/$IMAGE_NAME:$TAG_NAME | ||
docker run -d -p 50001:50001 --name $CONTAINER_NAME -t $REGISTRY/$IMAGE_NAME:$TAG_NAME |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
.idea | ||
/bin/ | ||
#.idea | ||
#/bin/ | ||
|
||
|
||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
# Directory with binary files | ||
/bin/ | ||
|
||
# Tests coverage | ||
coverage.* | ||
|
||
# Certificates and private keys | ||
/tls/ | ||
|
||
# Access token for testing | ||
.access_token |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.