-
Notifications
You must be signed in to change notification settings - Fork 123
185 lines (152 loc) · 5.65 KB
/
screenshots.yml
File metadata and controls
185 lines (152 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Screenshots
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
env:
CONFIGURE_ENCRYPTION_KEY: ${{ secrets.CONFIGURE_ENCRYPTION_KEY }}
jobs:
build:
name: Build Application
# Only run for PRs from the same repo (not forks) and with the 'generate screenshots' label
if: |
github.event.pull_request.head.repo.fork != true &&
contains(github.event.pull_request.labels.*.name, 'generate screenshots')
runs-on: macos-latest
steps:
- name: "Check out Project"
uses: actions/checkout@v4
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install App Dependencies
run: bundle exec rake dependencies
- name: Compile the App
run: bundle exec fastlane build_screenshots
- name: Archive Build Products
uses: actions/upload-artifact@v4
with:
name: screenshot-build-products
path: fastlane/DerivedData/Build/Products/Debug-iphonesimulator/
retention-days: 1
capture:
name: Capture
needs: build
runs-on: macos-latest
strategy:
matrix:
language: [ar-SA, de-DE, en-US, es-ES, fr-FR, he, id, it, ja, ko, nl-NL, pt-BR, ru, sv, tr, zh-Hans, zh-Hant]
mode: [dark, light]
steps:
- uses: actions/checkout@v4
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install Fastlane Dependencies
run: bundle exec fastlane run configure_apply
- name: Download Build Products
uses: actions/download-artifact@v4
with:
name: screenshot-build-products
path: fastlane/DerivedData/Build/Products/Debug-iphonesimulator/
- name: Generate Screenshots
run: |
bundle exec fastlane take_screenshots languages:${{ matrix.language }} mode:${{ matrix.mode }}
- name: Store Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: "screenshot-log-${{ matrix.language }}-${{ matrix.mode }}"
path: fastlane/logs
- name: Archive Generated Screenshots
uses: actions/upload-artifact@v4
with:
name: "screenshots-${{ matrix.language }}-${{ matrix.mode }}"
path: fastlane/screenshots/
process:
name: "Process Screenshots"
needs: capture
runs-on: macos-latest
permissions:
# Push the generated-screenshots branch
contents: write
# Create PR from the generated-screenshots branch to the original PR branch
pull-requests: write
env:
BUNDLE_WITH: screenshots
steps:
- uses: actions/checkout@v4
with:
# Checkout the PR branch directly (not the merge commit) so we can push back to it
ref: ${{ github.head_ref }}
# Fetch LFS files for promo screenshot generation
lfs: true
- name: Create screenshots branch
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
SCREENSHOTS_BRANCH="generated-screenshots/${COMMIT_SHA}"
echo "SCREENSHOTS_BRANCH=${SCREENSHOTS_BRANCH}" >> $GITHUB_ENV
git checkout -b "${SCREENSHOTS_BRANCH}"
- name: Install Native Dependencies
run: |
brew install imagemagick@7
brew link imagemagick@7 --force
brew install automattic/build-tools/drawText
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install Fastlane Dependencies
run: bundle exec fastlane run configure_apply
- name: Download Generated Screenshots
uses: actions/download-artifact@v4
with:
pattern: "screenshots-*"
path: fastlane/screenshots/
merge-multiple: true
- name: Generate Screenshot Summary
run: |
bundle exec fastlane create_screenshot_summary
- name: Upload Screenshot Summary
uses: actions/upload-artifact@v4
with:
name: screenshot-summary
path: fastlane/screenshots/screenshots.html
- name: Archive Raw Screenshots
uses: actions/upload-artifact@v4
with:
name: raw-screenshots
path: fastlane/screenshots
- name: Configure Git for committing
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Generate Promo Screenshots
run: |
bundle exec fastlane create_promo_screenshots force:true commit:true
- name: Archive Promo Screenshots
uses: actions/upload-artifact@v4
with:
name: promo-screenshots
path: fastlane/promo_screenshots
- name: Push screenshots branch and create PR
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check if there are any commits to push (the lane may have committed nothing)
if git diff --quiet origin/${{ github.head_ref }}..HEAD; then
echo "No new screenshots to commit"
exit 0
fi
git push origin "${SCREENSHOTS_BRANCH}"
# Note: GHA doesn't provide a run URL variable, so we build it from components
gh pr create \
--base "${{ github.head_ref }}" \
--head "${SCREENSHOTS_BRANCH}" \
--label "category: screenshots" \
--title "Add generated screenshots" \
--body "This PR adds the screenshots generated from #${{ github.event.pull_request.number }}.
Merge this PR to add the screenshots to your branch.
---
_Automatically generated by the [Screenshots workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})._"