This commit is contained in:
parent
2014206711
commit
1dc450ce38
|
@ -1,38 +1,71 @@
|
||||||
run-name: Create and publish a Docker image
|
run-name: ${{ gitea.actor }}, deploy with ssh
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: registry.log101.dev
|
BUILD_PATH: "."
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push-image:
|
build:
|
||||||
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Log in to the Container registry
|
- name: Detect package manager
|
||||||
uses: docker/login-action@v3
|
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:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
node-version: "20"
|
||||||
username: ${{ secrets.REGISTRY_USER }}
|
cache: ${{ steps.detect-package-manager.outputs.manager }}
|
||||||
password: ${{ secrets.REGISTRY_PASS }}
|
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Install dependencies
|
||||||
id: meta
|
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
|
||||||
uses: docker/metadata-action@v5
|
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:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
host: ${{ secrets.HOST }}
|
||||||
- name: Make envfile
|
username: ${{ secrets.USERNAME }}
|
||||||
uses: SpicyPizza/create-envfile@v2.0
|
key: ${{ secrets.KEY }}
|
||||||
with:
|
port: ${{ secrets.PORT }}
|
||||||
envkey_PUBLIC_BACKEND_HOST: ${{ vars.PUBLIC_BACKEND_HOST }}
|
script: |
|
||||||
- name: Build and push Docker image
|
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
|
||||||
id: push
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user