-
Notifications
You must be signed in to change notification settings - Fork 4
133 lines (121 loc) · 5.32 KB
/
update-screenshots.yml
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
name: update-screenshots
on:
pull_request:
types: [opened, reopened, labeled, synchronize]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
VIDEO_SERVICE_PROVIDER: ${{vars.VIDEO_SERVICE_PROVIDER}}
OT_API_KEY: ${{secrets.API_KEY}}
OT_API_SECRET: ${{secrets.API_SECRET}}
VONAGE_APP_ID: ${{secrets.VONAGE_APP_ID}}
VONAGE_PRIVATE_KEY: ${{secrets.VONAGE_PRIVATE_KEY}}
BRANCH_NAME: ${{ github.head_ref }}
REPO_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
run:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Check for "update-screenshots" label
id: check-update-screenshots
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const labels = pr.labels.map(label => label.name);
return labels.includes("update-screenshots");
- name: Update Screenshots
if: steps.check-update-screenshots.outputs.result == 'false'
run: |
echo "Update shreenshots is false"
- name: Install chrome latest
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt update && sudo apt install -y google-chrome-stable
echo "Check chrome version"
/usr/bin/google-chrome-stable --version
echo "Chrome latest downloaded and installed"
- name: Install edge latest
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
sudo rm microsoft.gpg
sudo apt update && sudo apt install -y microsoft-edge-stable
echo "Check edge version"
/usr/bin/microsoft-edge-stable --version
echo "Edge latest downloaded and installed"
- name: install firefox latest
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
sudo apt update
wget -O firefoxsetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"
sudo tar -xf firefoxsetup.tar.bz2 --directory /opt
echo "Check firefox version"
/opt/firefox/firefox --version
echo "Firefox latest downloaded and installed"
- name: install opera latest
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
sudo add-apt-repository 'deb https://deb.opera.com/opera-stable/ stable non-free'
wget -qO- https://deb.opera.com/archive.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install opera-stable -y
echo "Check opera version"
/usr/bin/opera --version
echo "Opera latest downloaded and installed"
- name: Checkout
if: steps.check-update-screenshots.outputs.result == 'true'
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Setup node
if: steps.check-update-screenshots.outputs.result == 'true'
uses: actions/setup-node@v3
with:
node-version: 22
cache: npm
- name: Install Dependencies
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
node -v
npm -v
npm install --global yarn
yarn
- name: Install electron dependencies
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-0 libx11-xcb1 libxcomposite1 libxrandr2 libxdamage1 libxi6 libxtst6 libnss3 libasound2
- name: Run integration tests
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
Xvfb :99 & export DISPLAY=:99
yarn test:integrationUpdateScreenshots
- name: Auto-commit updated screenshots
if: steps.check-update-screenshots.outputs.result == 'true'
run: |
echo "Committing screenshots to "$BRANCH_NAME""
FILES_CHANGED=$(git status --porcelain | awk '{print $2}')
for file in $FILES_CHANGED; do
CONTENT=$(base64 -w 0 "$file")
SHA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$REPO_NAME/contents/$file?ref=$BRANCH_NAME" | jq -r .sha)
if [ "$SHA" == "null" ]; then
SHA=""
fi
curl -s -X PUT -H "Authorization: token $GITHUB_TOKEN" \
-d "{\"message\":\"Commit screenshot file: $file\", \"content\":\"$CONTENT\", \"branch\":\"$BRANCH_NAME\", \"sha\":\"$SHA\"}" \
"https://api.github.com/repos/$REPO_NAME/contents/$file"
done