diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3183204..95940d6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,16 +25,20 @@ jobs: registry: ${{ env.REGISTRY_URL }} username: ${{ env.REGISTRY_USERNAME }} password: ${{ env.REGISTRY_PASSWORD }} + - name: Add custom builder + run: | + docker buildx create \ + --name container-builder \ + --driver docker-container \ + --bootstrap --use - name: Build & Publish backend to Github Container registry run: | - docker build --platform linux/amd64,linux/arm64 ./backend --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_backend:latest \ - --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_backend:$IMAGE_TAG - docker push $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_backend:latest - docker push $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_backend:$IMAGE_TAG + docker buildx build --platform linux/amd64,linux/arm64 --push ./backend \ + --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_backend:latest \ + --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_backend:$IMAGE_TAG - name: Build & Publish frontend to Github Container registry run: | - docker build --platform linux/amd64,linux/arm64 ./frontend --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_frontend:latest \ - --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_frontend:$IMAGE_TAG - docker push $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_frontend:latest - docker push $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_frontend:$IMAGE_TAG \ No newline at end of file + docker buildx build --platform linux/amd64,linux/arm64 --push ./frontend \ + --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_frontend:latest \ + --tag $REGISTRY_URL/$REGISTRY_USERNAME/yet_another_calendar_frontend:$IMAGE_TAG \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 82f4822..39bbc3c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -30,10 +30,14 @@ jobs: - run: ssh-keyscan -p $SSH_PORT $SSH_HOST >> ~/.ssh/known_hosts - run: ssh-agent -a $SSH_AUTH_SOCK > /dev/null - run: ssh-add - <<< "${{ secrets.SSH_KEY }}" - + - name: Add image tag to .version file + run: | + echo $IMAGE_TAG > .version + scp -P 666 .version $SSH_USER@$SSH_HOST:~/YetAnotherCalendar/.version + - name: Update docker compose run: | - ssh $SSH_USER@$SSH_HOST -p $SSH_PORT "cd YetAnotherCalendar/ && - YET_ANOTHER_CALENDAR_VERSION=$IMAGE_TAG docker compose -f docker-compose.prod.yaml pull - YET_ANOTHER_CALENDAR_VERSION=$IMAGE_TAG docker compose -f docker-compose.prod.yaml up -d" + ssh $SSH_USER@$SSH_HOST -p $SSH_PORT "cd YetAnotherCalendar/ && git pull origin main + YET_ANOTHER_CALENDAR_VERSION=$(cat .version) docker compose -f docker-compose.prod.yaml pull + YET_ANOTHER_CALENDAR_VERSION=$(cat .version) docker compose -f docker-compose.prod.yaml up -d" \ No newline at end of file diff --git a/.gitignore b/.gitignore index a7ef229..2c15530 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.version # Byte-compiled / optimized / DLL files __pycache__/