diff --git a/.github/workflows/build-qa-tag.yaml b/.github/workflows/build-qa-tag.yaml new file mode 100644 index 00000000..e61dd500 --- /dev/null +++ b/.github/workflows/build-qa-tag.yaml @@ -0,0 +1,64 @@ +# Builds a QA GHCR image for a PR when the "PR: Ready for QA" label is present. +# Triggers on: +# - "PR: Ready for QA" label added to a PR +# - New commits pushed to a PR that already has the label will trigger a new build +name: Build QA GHCR Image + +on: + pull_request: + types: [labeled, synchronize] + paths-ignore: + - "**.md" + - ".gitmodules" + - "cloud-deployments/**/*" + - "images/**/*" + - ".vscode/**/*" + - "**/.env.example" + - ".github/ISSUE_TEMPLATE/**/*" + - ".devcontainer/**/*" + - "embed/**/*" + - "browser-extension/**/*" + - "extras/**/*" + +concurrency: + group: qa-build-pr-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build: + name: Build and push QA image for PR + runs-on: ubuntu-22.04-arm + # Run when labeled with "PR: Ready for QA" + if: contains(github.event.pull_request.labels.*.name, 'PR: Ready for QA') + permissions: + packages: write + contents: read + pull-requests: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + version: v0.22.0 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/Dockerfile + push: true + sbom: true + provenance: mode=max + platforms: linux/arm64 + tags: ghcr.io/${{ github.repository_owner }}/anythingllm:pr-${{ github.event.pull_request.number }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/cleanup-qa-tag.yaml b/.github/workflows/cleanup-qa-tag.yaml new file mode 100644 index 00000000..acc00950 --- /dev/null +++ b/.github/workflows/cleanup-qa-tag.yaml @@ -0,0 +1,24 @@ +# Cleans up the GHCR image tag when the PR is closed or the "PR: Ready for QA" label is removed. +name: Cleanup QA Docker Image + +on: + pull_request: + types: [closed, unlabeled] + +jobs: + cleanup: + name: Delete QA image tag from GHCR + runs-on: ubuntu-latest + if: | + (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'PR: Ready for QA')) || + (github.event.action == 'unlabeled' && github.event.label.name == 'PR: Ready for QA') + permissions: + packages: write + steps: + - name: Delete PR tag from GHCR + uses: actions/delete-package-versions@v5 + with: + package-name: anythingllm + package-type: container + min-versions-to-keep: 0 + ignore-versions: '^(?!pr-${{ github.event.pull_request.number }}$).*$'