feat(indicators): create bollinder bands #123
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: Deploy Services | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get -y install docker-ce docker-ce-cli containerd.io | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Determine updated services | |
id: services | |
run: | | |
services=$(git log -1 --pretty=format:%s | grep -o -P "(?<=\().*?(?=\))") | |
echo "::set-output name=services::$services" | |
- name: Determine version number | |
id: version | |
run: | | |
version=$(git log -1 --pretty=format:%h) | |
echo "::set-output name=version::$version" | |
- name: Build Services | |
id: build | |
env: | |
DOCKER_COMPOSE_PATH: deploy/docker-compose.yml | |
run: | | |
IFS=',' read -ra services_array <<< "${{ steps.services.outputs.services }}" | |
version=${{ steps.version.outputs.version }} | |
for service in "${services_array[@]}"; do | |
echo "Building $service" | |
docker build -f services/$service/deploy/Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/$service:$version . | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/$service:$version | |
done | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Determine version number | |
id: version | |
run: | | |
version=$(git log -1 --pretty=format:%h) | |
echo "::set-output name=version::$version" | |
- name: Determine updated services | |
id: services | |
run: | | |
services=$(git log -1 --pretty=format:%s | grep -o -P "(?<=\().*?(?=\))") | |
echo "::set-output name=services::$services" | |
- name: SSH into VPS and Deploy | |
run: | | |
IFS=',' read -ra services_array <<< "${{ steps.services.outputs.services }}" | |
version=${{ steps.version.outputs.version }} | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ssh_key | |
chmod 600 ssh_key | |
ssh -i ssh_key -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_ADDRESS }} "mkdir -p ./gate/deploy" | |
scp -i ssh_key deploy/docker-compose.yml ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_ADDRESS }}:./gate/deploy | |
ssh_command="cd ./gate/deploy" | |
for service in "${services_array[@]}"; do | |
ssh_command+=" && VERSION=${version} docker-compose -f docker-compose.yml up -d ${service}" | |
done | |
ssh -o StrictHostKeyChecking=no -i ssh_key ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_ADDRESS }} "${ssh_command}" | |
rm ssh_key |