Browse Source

fix(ci): Add visual-diff with workflow_run for forks (#33609)

`visual-diff.yml` got removed in #33455
It allowed running Visual Snapshots on forks.
Armen Zambrano G 2 years ago
parent
commit
9b00053898
2 changed files with 28 additions and 1 deletions
  1. 1 1
      .github/workflows/acceptance.yml
  2. 27 0
      .github/workflows/visual-diff.yml

+ 1 - 1
.github/workflows/acceptance.yml

@@ -308,7 +308,7 @@ jobs:
     needs: [acceptance, frontend, chartcuterie]
     name: triggers visual snapshot
     # Do not execute on forks or on master
-    if: github.repository == 'getsentry/sentry' && github.ref != 'refs/heads/master'
+    if: github.head_repository.full_name == 'getsentry/sentry' && github.ref != 'refs/heads/master'
     runs-on: ubuntu-20.04
     timeout-minutes: 20
 

+ 27 - 0
.github/workflows/visual-diff.yml

@@ -0,0 +1,27 @@
+name: visual diff
+on:
+  # This allows PRs opened from forks to execute the Visual Snapshots
+  # since secrets are not passed to workflows when triggered via forks
+  # Using workflow_run is less preferred since it executes even when jobs
+  # do not pass
+  workflow_run:
+    workflows:
+      - acceptance
+    types:
+      - completed
+
+jobs:
+  visual-diff:
+    # This is the opposite condition as acceptance.yml/visual-diff
+    if: github.head_repository.full_name != 'getsentry/sentry'
+    runs-on: ubuntu-20.04
+    timeout-minutes: 20
+
+    steps:
+      - name: Diff snapshots
+        id: visual-snapshots-diff
+        uses: getsentry/action-visual-snapshot@v2
+        with:
+          api-token: ${{ secrets.VISUAL_SNAPSHOT_SECRET }}
+          gcs-bucket: 'sentry-visual-snapshots'
+          gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}