ci: deploy with rsync
Some checks failed
/ Build (push) Failing after 17s

This commit is contained in:
log101 2024-06-11 13:51:28 +03:00
parent 2014206711
commit 1dc450ce38

View File

@ -1,38 +1,71 @@
run-name: Create and publish a Docker image
run-name: ${{ gitea.actor }}, deploy with ssh
on: [push]
env:
REGISTRY: registry.log101.dev
IMAGE_NAME: ${{ github.repository }}
BUILD_PATH: "."
jobs:
build-and-push-image:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
working-directory: ${{ env.BUILD_PATH }}
- name: Build with Astro
run: |
${{ steps.detect-package-manager.outputs.runner }} astro build
working-directory: ${{ env.BUILD_PATH }}
- name: Deploy to my server
uses: up9cloud/action-rsync@master
env:
HOST: ${{ secrets.HOST }}
KEY: ${{ secrets.KEY }}
TARGET: ${{ secrets.DESTINATION_FOLDER }}
VERBOSE: true
USER: ${{ secrets.USERNAME }}
ARGS: -az --exclude=/.git/
SSH_ARGS: "-p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
SOURCE: ./dist/
PRE_SCRIPT: |
echo start at:
date -u
POST_SCRIPT: "echo done at: && date -u"
- name: Send mail
uses: appleboy/ssh-action@v1.0.3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Make envfile
uses: SpicyPizza/create-envfile@v2.0
with:
envkey_PUBLIC_BACKEND_HOST: ${{ vars.PUBLIC_BACKEND_HOST }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
echo -e "Subject: Act Runner Report: ${{ job.status}}\nFrom: gitea@log101.dev\n\nJob has finished with status ${{ job.status }}\n${{ github.repository }}: [${{ github.ref }}@${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions)" | sendmail ffrknerdm@gmail.com