Skip to content

Commit

Permalink
Add GitHub actions support
Browse files Browse the repository at this point in the history
  • Loading branch information
marksuth committed Aug 30, 2024
1 parent c251c92 commit 4261740
Show file tree
Hide file tree
Showing 4 changed files with 2,138 additions and 188 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
# Maintain dependencies for npm
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy to Server

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build-vite:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm

- name: Install npm dependencies
run: npm ci

- name: Build assets
run: npm run build

- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m 'Build assets'
git push origin main
deploy:
name: Deploy to server
runs-on: ubuntu-latest
needs: build-vite

steps:
- name: Establish connection
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
- name: Deploying updates to site
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && php artisan down --retry=15 && git pull && composer install --no-dev --optimize-autoloader && php artisan migrate --force && php artisan optimize:clear && php artisan up && exit"

- name: cleanup
run: rm -rf ~/.ssh
Loading

0 comments on commit 4261740

Please sign in to comment.