44 lines
1.2 KiB
YAML
44 lines
1.2 KiB
YAML
name: Main CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build and push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- uses: docker/login-action@v1
|
|
with:
|
|
registry: registry.btwazure.com
|
|
username: ${{ secrets.HARBOR_USERNAME }}
|
|
password: ${{ secrets.HARBOR_PASSWORD }}
|
|
- name: Build & Push
|
|
env:
|
|
REGISTRY: ${{ secrets.REGISTRY }}
|
|
IMAGE_TAG: ${{gitea.sha}}
|
|
run: |
|
|
docker build --pull --no-cache=true --tag $REGISTRY --tag $REGISTRY:$IMAGE_TAG .
|
|
docker push $REGISTRY
|
|
docker push $REGISTRY:$IMAGE_TAG
|
|
docker rmi $(docker images -q $REGISTRY:$IMAGE_TAG) -f
|
|
deploy:
|
|
name: Deploy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Pull & Restart
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.SSH_VM_DEPLOYMENT_HOST }}
|
|
key: ${{ secrets.SSH_VM_DEPLOYMENT }}
|
|
username: ${{ secrets.SSH_VM_DEPLOYMENT_USERNAME }}
|
|
port: ${{ secrets.SSH_VM_DEPLOYMENT_PORT }}
|
|
script: |
|
|
cd ~/deployment/genpdf
|
|
docker compose pull
|
|
docker compose down -v
|
|
docker compose up -d |