Initial commit

This commit is contained in:
Ceferino Patino 2024-11-18 20:20:09 -06:00
commit 7222a8c3fe
Signed by: c4patino
SSH key fingerprint: SHA256:9fQ9TsujGrdNNi76mnsu63v7dS5JOmHRZEqBOl49OR8
21 changed files with 4992 additions and 0 deletions

95
.github/workflows/ci-cd.yml vendored Normal file
View file

@ -0,0 +1,95 @@
name: CI / CD
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
increment:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.ref == 'refs/heads/main')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Determine PR merge or direct push
id: pr-merge
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.event.head_commit.message }}" == "Merge pull request"* ]]; then
echo "This is a PR merge commit."
echo "::set-output name=pr_merge::true"
else
echo "This is a direct push to main."
echo "::set-output name=pr_merge::false"
fi
- name: Determine version bump type
id: version-bump
run: |
pr_merge="${{ steps.check-pr-merge.outputs.pr_merge }}"
if [ "$pr_merge" == "true" ]; then
tags="${{ steps.get_pr_tags.outputs.tags }}"
bump_type="patch"
if [[ "$tags" =~ "major" ]]; then
bump_type="major"
elif [[ "$tags" =~ "minor" ]]; then
bump_type="minor"
fi
echo "PR merge detected. Bumping version as $bump_type."
else
bump_type="patch"
echo "Direct push to main detected. Bumping version as patch."
fi
echo "::set-output name=bump_type::$bump_type"
- name: npm version bump
run: |
npm version --${{ steps.version-bump.outputs.bump_type }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
commit_message: "[skip ci] Incrementing project version"
build:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: increment
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Connect to tailscale
uses: tailscale/github-action@v2
with:
authkey: ${{ secrets.TAILSCALE_AUTH_KEY }}
- name: Setup Node.js environment
uses: actions/setup-node@v4.1.0
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies and build
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
pnpm install
pnpm build
- name: Deploy build files
env:
REMOTE_USER: ${{ secrets.REMOTE_USER }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_DIR: ${{ secrets.REMOTE_DIR }}
run: rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no" ./.next $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR
- name: Reload PM2 configuration
env:
REMOTE_USER: ${{ secrets.REMOTE_USER }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
run: ssh -o StrictHostKeyChecking=no $REMOTE_USER@$REMOTE_HOST "pm2 reload days-since"