From 62f1de26684e2ab44c4e59fb713e6bb75ce1479f Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 29 May 2024 10:51:39 -0400 Subject: [PATCH] [28] add PR Builds --- .github/workflows/validate.yml | 107 ++++++++++++++++++++++++++++++++- VERSION | 2 +- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 5e06018b..fab28bd2 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -3,6 +3,7 @@ name: Validate Pull Request on: pull_request jobs: + validate-pull: runs-on: ubuntu-latest steps: @@ -24,4 +25,108 @@ jobs: uses: actions/checkout@v4 - name: Run Spellcheck - uses: rojopolis/spellcheck-github-actions@0.36.0 \ No newline at end of file + uses: rojopolis/spellcheck-github-actions@0.36.0 + + verify-changes: + runs-on: ubuntu-latest + needs: [ validate-pull ] + if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.base_ref == 'nightly' && startswith(github.head_ref, 'docker-') + outputs: + build: ${{ steps.list-changes.outputs.build }} + tag: ${{ steps.create-tag.outputs.docker-tag }} + steps: + + - name: Create Tag + id: create-tag + run: | + var="${{ github.head_ref }}" + echo "docker-tag=${var:7}" >> $GITHUB_OUTPUT + + - name: Check Out Repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + + - name: Get changes + id: get-changes + run: echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT + + - name: List changed files + id: list-changes + run: | + for file in ${{ steps.get-changes.outputs.files }}; do + if [[ $file =~ ^(defaults|fonts|modules|kometa.py|requirements.txt|.dockerignore|Dockerfile).*$ ]] ; then + echo "$file will trigger docker build" + echo "build=true" >> $GITHUB_OUTPUT + else + echo "$file will not trigger docker build" + fi + done + + docker-build: + runs-on: ubuntu-latest + needs: [ verify-changes ] + if: needs.verify-changes.outputs.build == 'true' + steps: + + - name: Check Out Repo + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push + id: docker_build + uses: docker/build-push-action@v5 + with: + context: ./ + file: ./Dockerfile + build-args: | + "BRANCH_NAME=${{ needs.verify-changes.outputs.tag }}" + platforms: linux/amd64,linux/arm64 + push: true + tags: kometateam/kometa:${{ needs.verify-changes.outputs.tag }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Discord Success Notification + uses: Kometa-Team/discord-notifications@master + if: success() + with: + webhook_id_token: ${{ secrets.BUILD_WEBHOOK }} + title: "${{ vars.REPO_NAME }} ${{ needs.verify-changes.outputs.tag }}: ${{ vars.TEXT_SUCCESS }}" + url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/actions/runs/${{ github.run_id }} + color: ${{ vars.COLOR_SUCCESS }} + username: ${{ vars.BOT_NAME }} + avatar_url: ${{ vars.BOT_IMAGE }} + author: ${{ vars.DOCKER_NAME }} + author_icon_url: ${{ vars.DOCKER_IMAGE }} + + - name: Discord Failure Notification + uses: Kometa-Team/discord-notifications@master + if: failure() + with: + webhook_id_token: ${{ secrets.BUILD_WEBHOOK }} + message: ${{ vars.BUILD_FAILURE_ROLE }} + title: "${{ vars.REPO_NAME }} ${{ needs.verify-changes.outputs.tag }}: ${{ vars.TEXT_FAILURE }}" + url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/actions/runs/${{ github.run_id }} + color: ${{ vars.COLOR_FAILURE }} + username: ${{ vars.BOT_NAME }} + avatar_url: ${{ vars.BOT_IMAGE }} + author: ${{ vars.DOCKER_NAME }} + author_icon_url: ${{ vars.DOCKER_IMAGE }} \ No newline at end of file diff --git a/VERSION b/VERSION index 56762f5e..f875567a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.1-develop27 +2.0.1-develop28