-
-
Notifications
You must be signed in to change notification settings - Fork 709
101 lines (99 loc) · 5.6 KB
/
create_webdriver_update.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
name: Create Webdriver Update PR
on:
schedule:
- cron: '0 23 * * *'
workflow_dispatch:
inputs:
chrome_version:
description: 'ChromeDriver version?'
required: false
default: 'cxx'
gecko_version:
description: 'geckodriver version?'
required: false
default: 'gxx'
jobs:
create_pr:
name: Create Pull Request
runs-on: ubuntu-latest
steps:
- name: Build Feature Branch and Raise PR
run: |
sudo apt install jq -y
# Setup git details
export GITHUB_USER=zapbot
git config --global user.email "[email protected]"
git config --global user.name $GITHUB_USER
# Clone repos
git clone -o upstream https://github.com/zaproxy/zap-extensions.git
cd zap-extensions
git remote add origin https://github.com/$GITHUB_USER/zap-extensions.git
# Setup env vars for later
BRANCH="webdriver-update"
export GITHUB_TOKEN=${{ secrets.ZAPBOT_TOKEN }}
IS_UPDT=0
# Get ChromeDriver version
CHROME_INPUT="${{ github.event.inputs.chrome_version }}"
echo $CHROME_INPUT
CHROME_INPUT=${CHROME_INPUT:-"cxx" }
echo $CHROME_INPUT
if [ $CHROME_INPUT == "cxx" ]; then
CHROME_VERS=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json|jq -r .channels.Stable.version)
else
CHROME_VERS=${{ github.event.inputs.chrome_version }}
fi
echo $CHROME_VERS
# Get geckodriver version
GECKO_INPUT="${{ github.event.inputs.gecko_version }}"
echo $GECKO_INPUT
GECKO_INPUT=${GECKO_INPUT:-"gxx" }
echo $GECKO_INPUT
if [ $GECKO_INPUT == "gxx" ]; then
GECKO_VERS=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest|jq -r .name)
else
GECKO_VERS=${{ github.event.inputs.gecko_version }}
fi
echo $GECKO_VERS
# Build the feature branch
git checkout -b $BRANCH
git remote set-url origin https://$GITHUB_USER:[email protected]/$GITHUB_USER/zap-extensions.git
# Update ChromeDriver version strings in help and build file
sed -i -e 's|val chromeDriverVersion = "[0-9\.]*"|val chromeDriverVersion = "'"$CHROME_VERS"'"|g' addOns/webdrivers/webdrivers.gradle.kts
sed -i -e "s|Chrome - ChromeDriver [0-9\.]*</li>|Chrome - ChromeDriver $CHROME_VERS</li>|g" addOns/webdrivers/webdriverlinux/src/main/javahelp/org/zaproxy/zap/extension/webdriverlinux/resources/help/contents/webdriverlinux.html
sed -i -e "s|Chrome - ChromeDriver [0-9\.]*</li>|Chrome - ChromeDriver $CHROME_VERS</li>|g" addOns/webdrivers/webdrivermacos/src/main/javahelp/org/zaproxy/zap/extension/webdrivermacos/resources/help/contents/webdrivermacos.html
sed -i -e "s|Chrome - ChromeDriver [0-9\.]*</li>|Chrome - ChromeDriver $CHROME_VERS</li>|g" addOns/webdrivers/webdriverwindows/src/main/javahelp/org/zaproxy/zap/extension/webdriverwindows/resources/help/contents/webdriverwindows.html
git update-index -q --refresh
# If there are changes update changelog, and commit
if ! git diff-index --quiet HEAD --; then
IS_UPDT=1
./gradlew :addOn:webdrivers:webdriverlinux:updateChangelog --change="- Update ChromeDriver to $CHROME_VERS."
./gradlew :addOn:webdrivers:webdrivermacos:updateChangelog --change="- Update ChromeDriver to $CHROME_VERS."
./gradlew :addOn:webdrivers:webdriverwindows:updateChangelog --change="- Update ChromeDriver to $CHROME_VERS."
git add .
git commit -m "Webdriver Update" -m "ChromeDriver update to $CHROME_VERS" --signoff
fi
# Update geckodriver version strings in help and build file
sed -i -e 's|val geckodriverVersion = "[0-9\.]*"|val geckodriverVersion = "'"$GECKO_VERS"'"|g' addOns/webdrivers/webdrivers.gradle.kts
sed -i -e "s|Firefox - geckodriver [0-9\.]*</li>|Firefox - geckodriver $GECKO_VERS</li>|g" addOns/webdrivers/webdriverlinux/src/main/javahelp/org/zaproxy/zap/extension/webdriverlinux/resources/help/contents/webdriverlinux.html
sed -i -e "s|Firefox - geckodriver [0-9\.]*</li>|Firefox - geckodriver $GECKO_VERS</li>|g" addOns/webdrivers/webdrivermacos/src/main/javahelp/org/zaproxy/zap/extension/webdrivermacos/resources/help/contents/webdrivermacos.html
sed -i -e "s|Firefox - geckodriver [0-9\.]*</li>|Firefox - geckodriver $GECKO_VERS</li>|g" addOns/webdrivers/webdriverwindows/src/main/javahelp/org/zaproxy/zap/extension/webdriverwindows/resources/help/contents/webdriverwindows.html
git update-index -q --refresh
# If there are changes update changelog, and commit
if ! git diff-index --quiet HEAD --; then
IS_UPDT=1
./gradlew :addOn:webdrivers:webdriverlinux:updateChangelog --change="- Update geckodriver to $GECKO_VERS."
./gradlew :addOn:webdrivers:webdrivermacos:updateChangelog --change="- Update geckodriver to $GECKO_VERS."
./gradlew :addOn:webdrivers:webdriverwindows:updateChangelog --change="- Update geckodriver to $GECKO_VERS."
git add .
git commit -m "Webdriver Update" -m "geckodriver update to $GECKO_VERS" --signoff
fi
if [ "$CHROME_VERS" == "null" ] || [ "$GECKO_VERS" == "null" ]; then
echo "Could not retrieve one (or both) of the new version identifiers"
exit
fi
## If there are changes: push and PR
if [ $IS_UPDT -eq 1 ]; then
git push --set-upstream origin $BRANCH --force
# Open the PR
hub pull-request --no-edit
fi