Skip to content

Create Tech Detection Update PR #2

Create Tech Detection Update PR

Create Tech Detection Update PR #2

name: Create Tech Detection Update PR
on:
schedule:
- cron: '0 4 3 * *'
workflow_dispatch:
jobs:
create_pr:
name: Create Pull Request
runs-on: ubuntu-latest
steps:
- name: Build Feature Branch and Raise PR
run: |
# Setup git details
export GITHUB_USER=zapbot
git config --global user.email "[email protected]"
git config --global user.name $GITHUB_USER
# Clone repos
SRC_REPO="enthec/webappanalyzer"
git clone https://github.com/$SRC_REPO.git --depth 1 techs
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
cd ../techs
# Setup env vars for later
SRC_BASE=$SRC_REPO"@"$(git log -1 --format=format:%h)
BRANCH="techs-update"
SHORT_DATE="$(date +"%Y-%m-%d")"
export GITHUB_TOKEN=${{ secrets.ZAPBOT_TOKEN }}
# Build the feature branch
cd ../zap-extensions
git checkout -b $BRANCH
cd ..
rm -rf zap-extensions/addOns/wappalyzer/src/main/resources/org/zaproxy/zap/extension/wappalyzer/resources/icons
chmod -R 664 techs/src/images/icons/*.*
cp -R techs/src/images/icons/ zap-extensions/addOns/wappalyzer/src/main/resources/org/zaproxy/zap/extension/wappalyzer/resources/icons
cp -f techs/src/technologies/*.json zap-extensions/addOns/wappalyzer/src/main/resources/org/zaproxy/zap/extension/wappalyzer/resources/technologies/
cp -f techs/src/categories.json zap-extensions/addOns/wappalyzer/src/main/resources/org/zaproxy/zap/extension/wappalyzer/resources/categories.json
cd zap-extensions
## Update the index to be sure git is aware of changes
git update-index -q --refresh
## If there are changes: comment, commit, PR
if ! git diff-index --quiet HEAD --; then
./gradlew :addOns:wappalyzer:updateChangelog --change="- Updated with enthec upstream icon and pattern changes."
git remote set-url origin https://$GITHUB_USER:[email protected]/$GITHUB_USER/zap-extensions.git
git add .
git commit -m "Tech Detection Update $SHORT_DATE" -m "Updates based on $SRC_BASE" --signoff
git push --set-upstream origin $BRANCH --force
# Open the PR
gh pr create -f
fi