97 lines
3.1 KiB
YAML
97 lines
3.1 KiB
YAML
name: pipeline
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
|
|
permissions:
|
|
packages: write
|
|
|
|
jobs:
|
|
build-and-push-images:
|
|
runs-on: debian-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: https://git.vhaudiquet.fr
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
|
|
|
- name: Build and push frontend docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./frontend
|
|
push: true
|
|
tags: |
|
|
git.vhaudiquet.fr/vhaudiquet/lolstats-frontend:latest
|
|
git.vhaudiquet.fr/vhaudiquet/lolstats-frontend:${{ github.sha }}
|
|
|
|
- name: Build and push patch_detector docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./patch_detector
|
|
push: true
|
|
tags: |
|
|
git.vhaudiquet.fr/vhaudiquet/lolstats-patch_detector:latest
|
|
git.vhaudiquet.fr/vhaudiquet/lolstats-patch_detector:${{ github.sha }}
|
|
|
|
- name: Build and push match_collector docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./match_collector
|
|
push: true
|
|
tags: |
|
|
git.vhaudiquet.fr/vhaudiquet/lolstats-match_collector:latest
|
|
git.vhaudiquet.fr/vhaudiquet/lolstats-match_collector:${{ github.sha }}
|
|
deploy:
|
|
runs-on: debian-latest
|
|
needs:
|
|
- build-and-push-images
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: |
|
|
docker-compose.yml
|
|
sparse-checkout-cone-mode: false
|
|
|
|
- name: Create and use env file
|
|
run: |
|
|
echo "Creating env file as: $(whoami) in: $(pwd)"
|
|
echo "GIT_COMMIT_HASH=${{ github.sha }}" >> .env
|
|
ls -la .env
|
|
|
|
- name: Log in to container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: https://git.vhaudiquet.fr
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
|
|
|
- name: Docker Stack deploy
|
|
run: |
|
|
echo "Running: ${0} as: $(whoami) in: $(pwd)"
|
|
mkdir -p /root/.ssh
|
|
chmod 0700 /root/.ssh
|
|
ssh-keyscan -p "22" -H "192.168.1.105" >> /root/.ssh/known_hosts
|
|
echo -e "\u001b[36mAdding SSH Key to SSH Agent"
|
|
echo "${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}" > /root/.ssh/id_rsa
|
|
chmod 0600 /root/.ssh/id_rsa
|
|
eval "$(ssh-agent -s)"
|
|
ssh-add /root/.ssh/id_rsa
|
|
echo -e "\u001b[36mVerifying Docker and Setting Context."
|
|
ssh -p "22" "root@192.168.1.105" "docker info" > /dev/null
|
|
docker context create remote --docker "host=ssh://root@192.168.1.105:22"
|
|
docker context ls
|
|
docker context use remote
|
|
echo -e "\u001b[36mSourcing Environment File: .env"
|
|
stat ".env"
|
|
set -a
|
|
source ".env"
|
|
echo -e "\u001b[36mDeploying Stack: \u001b[37;1mlolstats"
|
|
docker stack deploy -c "docker-compose.yml" "lolstats"
|