From 0381027dae317a43376895bb23c417699a1edf62 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Wed, 3 Jan 2024 12:26:46 +0100 Subject: [PATCH] Restore Github PAT in record screenshots, disable Maestro for forks (#2147) * Restore PAT for `recoverScreenshots.yml` flow. This is needed to trigger CI jobs automatically. In the case where this is not possible (forks) a message will be added to ask the user to add an empty commit to trigger the CI. * Add community PR notice * Disable Maestro steps for fork PRs --- .github/workflows/fork-pr-notice.yml | 30 +++++++++++++++++++++++++ .github/workflows/maestro.yml | 6 ++++- .github/workflows/recordScreenshots.yml | 3 ++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/fork-pr-notice.yml diff --git a/.github/workflows/fork-pr-notice.yml b/.github/workflows/fork-pr-notice.yml new file mode 100644 index 0000000000..dd697915f7 --- /dev/null +++ b/.github/workflows/fork-pr-notice.yml @@ -0,0 +1,30 @@ +name: Community PR notice + +on: + workflow_dispatch: + pull_request_target: + types: + - opened + - reopened + +jobs: + welcome: + runs-on: ubuntu-latest + name: Welcome comment + steps: + - name: Add auto-generated commit warning + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible: + + - Your branch should be based on `origin/develop`, at least when it was created. + - There is a changelog entry in the `changelog.d` folder with [the Towncrier format](https://towncrier.readthedocs.io/en/latest/tutorial.html#creating-news-fragments). + - The test pass locally running `./gradlew test`. + - The code quality check suite pass locally running `./gradlew runQualityChecks`. + - If you modified anything related to the UI, including previews, you'll have to run the `Record screenshots` GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, **it will prevent the CI from running temporarily**, until you upload a new commit after that one. To do so, just pull the latest changes and push [an empty commit](https://coderwall.com/p/vkdekq/git-commit-allow-empty).` + }) diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index a4bf0cc5ae..3b52235fb5 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -24,27 +24,31 @@ jobs: cancel-in-progress: true steps: - name: Remove Run-Maestro label - if: ${{ github.event.label.name == 'Run-Maestro' }} + if: ${{ !github.event.pull_request.fork && github.event.label.name == 'Run-Maestro' }} uses: actions-ecosystem/action-remove-labels@v1 with: labels: Run-Maestro - uses: actions/checkout@v4 + if: ${{ !github.event.pull_request.fork }} with: # Ensure we are building the branch and not the branch after being merged on develop # https://github.com/actions/checkout/issues/881 ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} - uses: actions/setup-java@v4 name: Use JDK 17 + if: ${{ !github.event.pull_request.fork }} with: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '17' - name: Assemble debug APK run: ./gradlew :app:assembleDebug $CI_GRADLE_ARG_PROPERTIES + if: ${{ !github.event.pull_request.fork }} env: ELEMENT_ANDROID_MAPTILER_API_KEY: ${{ secrets.MAPTILER_KEY }} ELEMENT_ANDROID_MAPTILER_LIGHT_MAP_ID: ${{ secrets.MAPTILER_LIGHT_MAP_ID }} ELEMENT_ANDROID_MAPTILER_DARK_MAP_ID: ${{ secrets.MAPTILER_DARK_MAP_ID }} - uses: mobile-dev-inc/action-maestro-cloud@v1.8.0 + if: ${{ !github.event.pull_request.fork }} with: api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }} # Doc says (https://github.com/mobile-dev-inc/action-maestro-cloud#android): diff --git a/.github/workflows/recordScreenshots.yml b/.github/workflows/recordScreenshots.yml index 8658fa2de7..11cd8e3352 100644 --- a/.github/workflows/recordScreenshots.yml +++ b/.github/workflows/recordScreenshots.yml @@ -43,7 +43,8 @@ jobs: with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - name: Record screenshots + id: record run: ./.github/workflows/scripts/recordScreenshots.sh env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN || secrets.GITHUB_TOKEN }} GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}