Skip to content

feat: Restructure Repo #11

feat: Restructure Repo

feat: Restructure Repo #11

Workflow file for this run

name: Build, Index, Push & Deploy
on:
push:
branches:
- main
- development
paths:
- "Source/Indexer/**"
- "Packages/**"
pull_request:
branches:
- main
- development
paths:
- "Source/Indexer/**"
- "Packages/**"
workflow_dispatch:
workflow_call:
secrets:
DEPLOY_HOST:
required: true
DEPLOY_USERNAME:
required: true
DEPLOY_KEY:
required: true
DEPLOY_FOLDER:
required: true
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v4
- name: Cache Indexer
id: cache-indexer
uses: actions/cache@v3
env:
cache-name: cache-indexer
with:
path: ./Source/Indexer/index
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./Source/Indexer/**') }}
- name: Install Dependencies
if: steps.cache-indexer.outputs.cache-hit != 'true'
run: sudo apt-get install -y libssl-dev pkg-config
- name: Build
if: steps.cache-indexer.outputs.cache-hit != 'true'
working-directory: ./Source/Indexer
run: |
cargo build --bin index --verbose --release
- name: Prepare Upload
if: steps.cache-indexer.outputs.cache-hit != 'true'
working-directory: ./Source/Indexer
run: |
cp target/release/index .
- name: Upload Indexer
uses: actions/upload-artifact@v4
with:
name: Indexer
path: |
./Source/Indexer/index
index:
needs: build
runs-on: ubuntu-latest
name: Index
steps:
- uses: actions/checkout@v4
- name: Download Indexer
uses: actions/download-artifact@v4
with:
name: Indexer
path: ./Indexer
- name: Prepare Indexer
run: chmod 770 ./Indexer/index
- name: Run Indexer
run: ./Indexer/index
- name: Upload Index
uses: actions/upload-artifact@v4
with:
name: Index
path: |
./index.zip
push-index:
needs: index
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
name: Push Index
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: index
- name: Download Index
uses: actions/download-artifact@v4
with:
name: Index
path: .
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Commit
run: |
git add index.zip
git commit -m "Update Index"
- name: Push
run: |
git push
deploy:
needs: push-index
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Docker Compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
script: |
cd ${{ secrets.DEPLOY_FOLDER }}
podman-compose up -d --force-recreate