From 21eb751c39a64498b695e884dfcae4e5be856cd7 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Thu, 12 Aug 2021 16:16:52 -0400 Subject: [PATCH] Updating docker workflows (#495) * Updating docker action * adding version to message * adding way to get PR title and body * Adding input pass to workflows Workflow dispatches may not get push header info. Switching logic to pass needed title and body info through just in case. * adding token The description on this action is awful, it didn't mention needing a token. I found this solution from the repo's issues * parsing pr body * Updating parsing * Updating docker workflow * Reverting back to default variables * fixing syntax error * removing heading syntax * updating parse * Updating parsing * Updating docker workflow * trying to remove newline * updating parsing * Replacement in parsing * Update sonar-scan.yml * testing passing pr body via artifact * Updating action version * syntax fix * Updating write * Updating write * testing artifact * consolidating nightly-docker into main workflow * pulling stable into main --- .github/workflows/nightly-docker.yml | 93 ----------------------- .github/workflows/sonar-scan.yml | 107 +++++++++++++++++++++++++-- .github/workflows/stable-docker.yml | 96 ------------------------ 3 files changed, 102 insertions(+), 194 deletions(-) delete mode 100644 .github/workflows/nightly-docker.yml delete mode 100644 .github/workflows/stable-docker.yml diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml deleted file mode 100644 index bdde18908..000000000 --- a/.github/workflows/nightly-docker.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Build Nightly Docker - -on: - workflow_dispatch: - inputs: - title: - description: "PR Title" - required: true - default: "" - -jobs: - docker: - name: Building Nightly Docker - runs-on: ubuntu-latest - steps: - - - name: Check Out Repo - uses: actions/checkout@v2 - with: - ref: develop - - - name: NodeJS to Compile WebUI - uses: actions/setup-node@v2.1.5 - with: - node-version: '14' - - run: | - cd UI/Web || exit - echo 'Installing web dependencies' - npm install - - echo 'Building UI' - npm run prod - - echo 'Copying back to Kavita wwwroot' - rsync -a dist/ ../../API/wwwroot/ - - cd ../ || exit - - - name: Get csproj Version - uses: naminodarie/get-net-sdk-project-versions-action@v1 - id: get-version - with: - proj-path: Kavita.Common/Kavita.Common.csproj - - - name: Echo csproj version - run: echo "${{steps.get-version.outputs.assembly-version}}" - - - name: Compile dotnet app - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '5.0.x' - - run: ./monorepo-build.sh - - - name: Trigger Sentry workflow - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: Sentry Map Release - token: ${{ secrets.REPO_GHA_PAT }} - inputs: '{ "version": "${{steps.get-version.outputs.assembly-version}}" }' - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - platforms: linux/amd64,linux/arm/v7,linux/arm64 - push: true - tags: kizaing/kavita:nightly - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} - - - name: Notify Discord - uses: rjstone/discord-webhook-notify@v1 - with: - severity: info - description: v${{steps.get-version.outputs.assembly-version}} - ${{ github.event.inputs.title }} - details: '${{ steps.parse-body.outputs.BODY }}' - text: A new nightly build has been released for docker. - webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index f17d7539b..eb688ef39 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -215,20 +215,117 @@ jobs: uses: rjstone/discord-webhook-notify@v1 with: severity: info - description: v${{steps.get-version.outputs.assembly-version}} - ${{ github.event.inputs.title }} + description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }} details: '${{ steps.parse-body.outputs.BODY }}' text: A new nightly build has been released for docker. webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} stable: - name: Trigger Stable Docker if Main push + name: Build Stable Docker if Main push needs: [ build, test ] runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} steps: - - name: If Push to Main, Trigger Docker Stable + - name: Find Current Pull Request + uses: jwalton/gh-find-current-pr@v1.0.2 + id: findPr + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Parse PR body + id: parse-body + run: | + body='${{ steps.findPr.outputs.body }}' + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo $body + echo "::set-output name=BODY::$body" + + - name: Check Out Repo + uses: actions/checkout@v2 + with: + ref: main + + - name: NodeJS to Compile WebUI + uses: actions/setup-node@v2.1.5 + with: + node-version: '14' + - run: | + + cd UI/Web || exit + echo 'Installing web dependencies' + npm install + + echo 'Building UI' + npm run prod + + echo 'Copying back to Kavita wwwroot' + rsync -a dist/ ../../API/wwwroot/ + + cd ../ || exit + + - name: Get csproj Version + uses: naminodarie/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: Kavita.Common/Kavita.Common.csproj + + - name: Echo csproj version + run: echo "${{steps.get-version.outputs.assembly-version}}" + + - name: Parse Version + run: | + version='${{steps.get-version.outputs.assembly-version}}' + newVersion=${version%.*} + echo $newVersion + echo "::set-output name=VERSION::$newVersion" + id: parse-version + + - name: Compile dotnet app + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '5.0.x' + - run: ./monorepo-build.sh + + - name: Trigger Sentry workflow uses: benc-uk/workflow-dispatch@v1 with: - workflow: Build Stable Docker - token: ${{ secrets.REPO_GHA_PAT }} \ No newline at end of file + workflow: Sentry Map Release + token: ${{ secrets.REPO_GHA_PAT }} + inputs: '{ "version": "${{steps.get-version.outputs.assembly-version}}" }' + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: kizaing/kavita:latest, kizaing/kavita:${{ steps.parse-version.outputs.VERSION }} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + - name: Notify Discord + uses: rjstone/discord-webhook-notify@v1 + with: + severity: info + description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }} + details: '${{ steps.parse-body.outputs.BODY }}' + text: A new stable build has been released. + webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} diff --git a/.github/workflows/stable-docker.yml b/.github/workflows/stable-docker.yml deleted file mode 100644 index cea58295b..000000000 --- a/.github/workflows/stable-docker.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Build Stable Docker - -on: - workflow_dispatch: - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Check Out Repo - uses: actions/checkout@v2 - with: - ref: main - - - name: NodeJS to Compile WebUI - uses: actions/setup-node@v2.1.5 - with: - node-version: '14' - - run: | - - cd UI/Web || exit - echo 'Installing web dependencies' - npm install - - echo 'Building UI' - npm run prod - - echo 'Copying back to Kavita wwwroot' - rsync -a dist/ ../../API/wwwroot/ - - cd ../ || exit - - - name: Get csproj Version - uses: naminodarie/get-net-sdk-project-versions-action@v1 - id: get-version - with: - proj-path: Kavita.Common/Kavita.Common.csproj - - - name: Echo csproj version - run: echo "${{steps.get-version.outputs.assembly-version}}" - - - name: Parse Version - run: | - version='${{steps.get-version.outputs.assembly-version}}' - newVersion=${version%.*} - echo $newVersion - echo "::set-output name=VERSION::$newVersion" - id: parse-version - - - name: Compile dotnet app - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '5.0.x' - - run: ./monorepo-build.sh - - - name: Trigger Sentry workflow - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: Sentry Map Release - token: ${{ secrets.REPO_GHA_PAT }} - inputs: '{ "version": "${{steps.get-version.outputs.assembly-version}}" }' - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - platforms: linux/amd64,linux/arm/v7,linux/arm64 - push: true - tags: kizaing/kavita:latest, kizaing/kavita:${{ steps.parse-version.outputs.VERSION }} - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} - - - name: Notify Discord - uses: rjstone/discord-webhook-notify@v1 - with: - severity: info - description: ${{ github.event.body }} - details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated' - text: A new stable build has been released for docker. - webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} \ No newline at end of file