mirror of
https://github.com/jaypyles/Scraperr.git
synced 2025-10-30 05:57:12 +00:00
feat: auto deploy
This commit is contained in:
22
.github/workflows/merge.yml
vendored
Normal file
22
.github/workflows/merge.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Merge
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
uses: ./.github/workflows/reusable/tests.yml
|
||||
secrets:
|
||||
openai_key: ${{ secrets.OPENAI_KEY }}
|
||||
|
||||
version:
|
||||
uses: ./.github/workflows/reusable/version.yml
|
||||
|
||||
build-and-deploy:
|
||||
needs: tests
|
||||
uses: ./.github/workflows/reusable/docker-image.yml
|
||||
secrets:
|
||||
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
20
.github/workflows/pr.yml
vendored
Normal file
20
.github/workflows/pr.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
types: [opened, synchronize, reopened]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
checkout:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
call-pr-tests:
|
||||
needs: checkout
|
||||
uses: ./.github/workflows/reusable/tests.yml
|
||||
secrets:
|
||||
openai_key: ${{ secrets.OPENAI_KEY }}
|
||||
@@ -1,6 +1,11 @@
|
||||
name: Docker Image
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
secrets:
|
||||
dockerhub_username:
|
||||
required: true
|
||||
dockerhub_token:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -1,14 +1,11 @@
|
||||
name: Unit Tests
|
||||
name: Reusable PR Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_call:
|
||||
secrets:
|
||||
openai_key:
|
||||
required: true
|
||||
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
@@ -54,7 +51,6 @@ jobs:
|
||||
if: steps.run-tests.outcome == 'failure'
|
||||
run: exit 1
|
||||
|
||||
|
||||
success-message:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
@@ -69,6 +65,6 @@ jobs:
|
||||
username: "Scraperr CI"
|
||||
embed-title: "✅ Deployment Status"
|
||||
embed-description: "Scraperr successfully passed all tests."
|
||||
embed-color: 3066993 # Green
|
||||
embed-color: 3066993
|
||||
embed-footer-text: "Scraperr CI"
|
||||
embed-timestamp: ${{ github.event.head_commit.timestamp }}
|
||||
52
.github/workflows/reusable/version.yml
vendored
Normal file
52
.github/workflows/reusable/version.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: Version
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get version bump
|
||||
id: version
|
||||
run: |
|
||||
# Get the last commit message
|
||||
COMMIT_MSG=$(git log -1 --pretty=%B)
|
||||
|
||||
# Determine version type based on commit message
|
||||
if [[ $COMMIT_MSG =~ ^feat\(breaking\) ]]; then
|
||||
VERSION_TYPE="major"
|
||||
elif [[ $COMMIT_MSG =~ ^feat! ]]; then
|
||||
VERSION_TYPE="minor"
|
||||
elif [[ $COMMIT_MSG =~ ^(feat|fix|chore): ]]; then
|
||||
VERSION_TYPE="patch"
|
||||
else
|
||||
VERSION_TYPE="patch" # Default to patch for other commit types
|
||||
fi
|
||||
|
||||
echo "version_type=$VERSION_TYPE" >> $GITHUB_ENV
|
||||
|
||||
- name: Set version
|
||||
run: |
|
||||
VERSION=$(./scripts/version.sh ${{ env.VERSION_TYPE }})
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "Version is $VERSION"
|
||||
|
||||
- name: Update chart file
|
||||
run: |
|
||||
# Update version in Chart.yaml
|
||||
sed -i "s/^version: .*/version: ${{ env.VERSION }}/" helm/Chart.yaml
|
||||
|
||||
# Commit and push the changes
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add helm/Chart.yaml
|
||||
git commit -m "chore: bump version to ${{ env.VERSION }}"
|
||||
git push
|
||||
|
||||
|
||||
19
scripts/version.sh
Executable file
19
scripts/version.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ARGS
|
||||
VERSION_TYPE=$1 # patch, minor, major
|
||||
|
||||
# Get the current version from the Chart.yaml file
|
||||
current_version=$(grep -oP 'version:\s*\K[0-9]+\.[0-9]+\.[0-9]+' helm/Chart.yaml | tr -d '[:space:]')
|
||||
|
||||
# Increment the version number
|
||||
if [ "$VERSION_TYPE" == "patch" ]; then
|
||||
new_version=$(echo $current_version | awk -F. -v OFS=. '{$NF++; print}')
|
||||
elif [ "$VERSION_TYPE" == "minor" ]; then
|
||||
new_version=$(echo $current_version | awk -F. -v OFS=. '{$2++; $3=0; print}')
|
||||
elif [ "$VERSION_TYPE" == "major" ]; then
|
||||
new_version=$(echo $current_version | awk -F. -v OFS=. '{$1++; $2=0; $3=0; print}')
|
||||
fi
|
||||
|
||||
# Output the new version
|
||||
echo "$new_version"
|
||||
Reference in New Issue
Block a user