From 18b0b2848d688dfed2fee94a71ec8aabe5e4a824 Mon Sep 17 00:00:00 2001 From: "Michael H." Date: Fri, 31 Jul 2026 13:10:58 +0200 Subject: [PATCH] feat: labrinth argo --- .github/workflows/cmd-deploy.yml | 19 +++++ ...labrinth-docker.yml => labrinth-build.yml} | 69 ++++++++----------- .github/workflows/slash-cmds.yml | 18 +++++ apps/labrinth/Dockerfile | 2 +- 4 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/cmd-deploy.yml rename .github/workflows/{labrinth-docker.yml => labrinth-build.yml} (66%) create mode 100644 .github/workflows/slash-cmds.yml diff --git a/.github/workflows/cmd-deploy.yml b/.github/workflows/cmd-deploy.yml new file mode 100644 index 000000000..010359a2e --- /dev/null +++ b/.github/workflows/cmd-deploy.yml @@ -0,0 +1,19 @@ +name: Deploy Command +run-name: Deploy PR #${{ github.event.client_payload.github.payload.issue.number }} + +on: + repository_dispatch: + types: [deploy-command] + +jobs: + deploy: + uses: SparkUniverse/workflows/.github/workflows/deploy-command.yaml@main + secrets: + ARGOCD_DEPLOY_KEY: ${{ secrets.ARGOCD_DEPLOY_KEY }} + CMD_DISPATCH_GH_TOKEN: ${{ secrets.SLASH_CMD_GH_TOKEN }} + with: + application-set: labrinth + build-workflow: labrinth-build.yml + branch: ${{ github.event.client_payload.pull_request.head.ref }} + issue-number: ${{ github.event.client_payload.github.payload.issue.number }} + head-sha: ${{ github.event.client_payload.pull_request.head.sha }} diff --git a/.github/workflows/labrinth-docker.yml b/.github/workflows/labrinth-build.yml similarity index 66% rename from .github/workflows/labrinth-docker.yml rename to .github/workflows/labrinth-build.yml index ce8d8effa..5aba8298a 100644 --- a/.github/workflows/labrinth-docker.yml +++ b/.github/workflows/labrinth-build.yml @@ -1,18 +1,18 @@ -name: docker-build +name: Labrinth Build on: push: branches: - 'main' paths: - - .github/workflows/labrinth-docker.yml + - .github/workflows/labrinth-build.yml - 'apps/labrinth/**' - Cargo.toml - Cargo.lock pull_request: types: [opened, synchronize] paths: - - .github/workflows/labrinth-docker.yml + - .github/workflows/labrinth-build.yml - 'apps/labrinth/**' - Cargo.toml - Cargo.lock @@ -69,7 +69,8 @@ jobs: echo "skip=false" >> $GITHUB_OUTPUT fi - docker: + build: + name: Build Labrinth runs-on: ${{ needs.skip-if-clean.outputs.internal == 'true' && 'namespace-profile-modrinth-labrinth' || 'ubuntu-latest' }} needs: [skip-if-clean] if: ${{ needs.skip-if-clean.outputs.skip != 'true' }} @@ -120,42 +121,30 @@ jobs: cp -r apps/labrinth/migrations apps/labrinth/docker-stage/migrations cp -r apps/labrinth/assets apps/labrinth/docker-stage/assets - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - - - name: Generate Docker image metadata - id: docker-meta - uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 - env: - # GitHub Packages requires annotations metadata in at least the index descriptor to show them - # up properly in its UI it seems, but it's not clear about it, because the docs refer to the - # image manifest only. See: - # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#adding-a-description-to-multi-arch-images - DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index + - name: Upload Docker context + if: needs.skip-if-clean.outputs.internal == 'true' + uses: namespace-actions/upload-artifact@f6ccaacc655aec41b93af180d1d7eef21af862d2 # v1.0.3 with: - images: ghcr.io/modrinth/labrinth - labels: | - org.opencontainers.image.title=labrinth - org.opencontainers.image.description=Modrinth API - org.opencontainers.image.licenses=AGPL-3.0-only - annotations: | - org.opencontainers.image.title=labrinth - org.opencontainers.image.description=Modrinth API - org.opencontainers.image.licenses=AGPL-3.0-only + name: labrinth-docker-context + retention-days: 1 + path: apps/labrinth/docker-stage - - name: Login to GitHub Packages - uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + docker-build: + needs: [skip-if-clean, build] + if: ${{ needs.skip-if-clean.outputs.internal == 'true' }} + uses: SparkUniverse/workflows/.github/workflows/docker-build.yaml@main + with: + image-name: labrinth + dockerfile-path: apps/labrinth/Dockerfile + artifacts-name: labrinth-docker-context - - name: Build and push - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 - with: - context: ./apps/labrinth/docker-stage - file: ./apps/labrinth/Dockerfile - push: true - tags: ${{ steps.docker-meta.outputs.tags }} - labels: ${{ steps.docker-meta.outputs.labels }} - annotations: ${{ steps.docker-meta.outputs.annotations }} + deploy: + needs: docker-build + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prod' }} + uses: SparkUniverse/workflows/.github/workflows/argo-update.yaml@main + secrets: + ARGOCD_DEPLOY_KEY: ${{ secrets.ARGOCD_DEPLOY_KEY }} + with: + application-set: labrinth + branch: ${{ github.ref == 'refs/heads/prod' && 'main' || 'develop' }} + environment-name: ${{ github.ref == 'refs/heads/prod' && 'production' || 'staging' }} diff --git a/.github/workflows/slash-cmds.yml b/.github/workflows/slash-cmds.yml new file mode 100644 index 000000000..65a6d8df2 --- /dev/null +++ b/.github/workflows/slash-cmds.yml @@ -0,0 +1,18 @@ +name: Slash Command Dispatch + +on: + issue_comment: + types: [created] + +jobs: + dispatch-command: + if: ${{ github.event.sender.type == 'User' && contains(fromJSON('["OWNER", "MEMBER"]'), github.event.comment.author_association) }} + runs-on: namespace-profile-tiny-arm64 + steps: + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@9bdcd7914ec1b75590b790b844aa3b8eee7c683a # v5.0.2 + with: + token: ${{ secrets.SLASH_CMD_GH_TOKEN }} + issue-type: pull-request + commands: | + deploy diff --git a/apps/labrinth/Dockerfile b/apps/labrinth/Dockerfile index 328c4137d..6d2923265 100644 --- a/apps/labrinth/Dockerfile +++ b/apps/labrinth/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates dumb-init curl \ && rm -rf /var/lib/apt/lists/* -COPY labrinth /labrinth/labrinth +COPY --chmod=0755 labrinth /labrinth/labrinth COPY migrations /labrinth/migrations COPY assets /labrinth/assets