Expands CI triggers and release conditions to include both main and master branches. Ensures workflows run consistently as the repository transitions or supports main as the default branch. Relates to MLO-469
106 lines
3.1 KiB
YAML
106 lines
3.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
branches: [main, master]
|
|
schedule:
|
|
- cron: 0 4 * * *
|
|
|
|
jobs:
|
|
test:
|
|
name: All checks are passed
|
|
uses: ./.github/workflows/test.yaml
|
|
secrets: inherit
|
|
|
|
approve:
|
|
name: Approve bot PR
|
|
runs-on: ubuntu-latest
|
|
if: endsWith(github.actor, '[bot]')
|
|
needs: test
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: metadata
|
|
id: metadata
|
|
if: github.actor == 'dependabot[bot]'
|
|
uses: dependabot/fetch-metadata@v2
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Enable auto-merge for bot PRs
|
|
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
|
|
env:
|
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
release-processor-image:
|
|
name: Release processor image
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
|
steps:
|
|
- name: Checkout commit
|
|
uses: actions/checkout@v4
|
|
- name: Purge old artifacts
|
|
uses: kolpav/purge-artifacts-action@v1
|
|
with:
|
|
token: ${{ github.token }}
|
|
expire-in: 30mins
|
|
- name: Login to ghcr.io
|
|
uses: docker/login-action@v3.5.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ github.token }}
|
|
- name: Release development image
|
|
run: |
|
|
make build-hook-image
|
|
- name: Release development image
|
|
run: |
|
|
export IMAGE_TAG=development
|
|
make push-hook-image
|
|
- name: Release prod image
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
export IMAGE_TAG=${GITHUB_REF#refs/tags/v}
|
|
make push-hook-image
|
|
|
|
release-processor-image-pr:
|
|
name: Release processor image from PR
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout commit
|
|
uses: actions/checkout@v4
|
|
- name: Purge old artifacts
|
|
uses: kolpav/purge-artifacts-action@v1
|
|
with:
|
|
token: ${{ github.token }}
|
|
expire-in: 30mins
|
|
- name: Login to ghcr.io
|
|
uses: docker/login-action@v3.5.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ github.token }}
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/neuro-inc/app-lightrag
|
|
tags: |
|
|
type=ref,event=pr
|
|
- name: Build Docker image
|
|
run: make build-hook-image
|
|
- name: Push release for testing
|
|
if: github.actor != 'dependabot[bot]'
|
|
run: |
|
|
FULL_IMAGE_NAME=${{ steps.meta.outputs.tags }}
|
|
export IMAGE_TAG=${FULL_IMAGE_NAME##*:}
|
|
make push-hook-image
|