Responsiveness #191
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: My single and only CI/CD pipe | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
env: | |
DESTINATION_DIR: /srv/www/xfenix-v2.ru | |
jobs: | |
build-front: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- uses: docker/setup-buildx-action@v1 | |
- uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-front- | |
- uses: docker/build-push-action@v2 | |
with: | |
context: ./front | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/xfenix-ru-front-v2:latest | |
- run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
build-back: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- uses: docker/setup-buildx-action@v1 | |
- uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-back- | |
- uses: docker/build-push-action@v2 | |
with: | |
context: ./back | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/xfenix-ru-back:latest | |
- run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
deploy-docker-compose: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: appleboy/scp-action@master | |
with: | |
host: xfenix.ru | |
username: ${{ secrets.XFENIXRU_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.XFENIXRU_PORT }} | |
source: "docker-compose.yml" | |
target: ${{ env.DESTINATION_DIR }} | |
deploy-site: | |
needs: [build-front, build-back, deploy-docker-compose] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: appleboy/ssh-action@master | |
with: | |
host: xfenix.ru | |
username: ${{ secrets.XFENIXRU_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.XFENIXRU_PORT }} | |
script: | | |
docker-compose -f ${{ env.DESTINATION_DIR }}/docker-compose.yml pull | |
docker-compose -f ${{ env.DESTINATION_DIR }}/docker-compose.yml down | |
docker-compose -f ${{ env.DESTINATION_DIR }}/docker-compose.yml up -d |