From bc352ba9de614f31ea779b3aee30533276410045 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 2 Jun 2023 15:53:06 +0200 Subject: [PATCH] Add GitHub workflow to record screenshots when manually triggered. --- .github/workflows/recordScreenshots.yml | 35 +++++++++++++++ .../workflows/scripts/recordScreenshots.sh | 43 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/recordScreenshots.yml create mode 100755 .github/workflows/scripts/recordScreenshots.sh diff --git a/.github/workflows/recordScreenshots.yml b/.github/workflows/recordScreenshots.yml new file mode 100644 index 0000000000..5e51571ae4 --- /dev/null +++ b/.github/workflows/recordScreenshots.yml @@ -0,0 +1,35 @@ +name: Record screenshots + +on: + workflow_dispatch: + inputs: + param_branch: + description: 'Branch to record the screenshots on' + required: true + type: string + +# Enrich gradle.properties for CI/CD +env: + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + +jobs: + record: + name: Record screenshots on branch ${{ inputs.param_branch }} + runs-on: ubuntu-latest + + steps: + - name: ⏬ Checkout with LFS + uses: actions/checkout@v3 + with: + lfs: 'true' + - name: ☕️ Use JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + - name: Record screenshots + run: "./.github/workflows/scripts/recordScreenshots.sh" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} + BRANCH: ${{ inputs.param_branch }} diff --git a/.github/workflows/scripts/recordScreenshots.sh b/.github/workflows/scripts/recordScreenshots.sh new file mode 100755 index 0000000000..fd2331d47a --- /dev/null +++ b/.github/workflows/scripts/recordScreenshots.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# +# Copyright (c) 2023 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if [[ -z ${GITHUB_TOKEN} ]]; then + echo "Missing GITHUB_TOKEN variable" + exit 1 +fi + +if [[ -z ${GITHUB_REPOSITORY} ]]; then + echo "Missing GITHUB_REPOSITORY variable" + exit 1 +fi + +if [[ -z ${BRANCH} ]]; then + echo "Missing BRANCH variable" + exit 1 +fi + +./gradlew recordPaparazziDebug --stacktrace -PpreDexEnable=false --max-workers 4 --warn + +git config user.name "ElementBot" +git config user.email "benoitm+elementbot@element.io" +git fetch --all +git checkout --track "origin/$BRANCH" +git add -A +git commit -m "Update screenshots" +git push "https://$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" +echo "Done!"